mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Michael Kelley <mhklinux@outlook.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hardening@vger.kernel.org"
	<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH v2][next] hyperv: Avoid a hundred -Wflex-array-member-not-at-end warnings
Date: Fri, 29 Aug 2025 18:17:03 +0200	[thread overview]
Message-ID: <dc494864-22c9-42a6-ba3b-f64ae753ae53@embeddedor.com> (raw)
In-Reply-To: <SN6PR02MB4157D4C3A66E0563A9071DF1D43AA@SN6PR02MB4157.namprd02.prod.outlook.com>



On 8/29/25 18:07, Michael Kelley wrote:
> From: Gustavo A. R. Silva <gustavoars@kernel.org> Sent: Friday, August 29, 2025 4:44 AM
>>
>> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
>> getting ready to enable it, globally.
>>
>> Use the new TRAILING_OVERLAP() helper to fix 159 of the following type
>> of warnings:
>>
>>      159 ./include/linux/hyperv.h:711:38: warning: structure containing a flexible array
>> member is not at the end of another structure [-Wflex-array-member-not-at-end]
>>
>> This helper creates a union between a flexible-array member (FAM)
>> and a set of members that would otherwise follow it. This overlays
>> the trailing members onto the FAM while preserving the original
>> memory layout.
>>
>> Also, move `struct vmbus_close_msg close_msg;` at the end of
>> `struct vmbus_channel`, as `struct vmbus_channel_msginfo,` ends
>> in a flexible array member.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> --
>> Changes in v2:
>>   - Fix subject line.
>>
>> v1:
>>   - Link: https://lore.kernel.org/linux-hardening/aLGSDpi4xDjUUYVm@kspp/
>>
>>   include/linux/hyperv.h | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
>> index a59c5c3e95fb..efdd570669fa 100644
>> --- a/include/linux/hyperv.h
>> +++ b/include/linux/hyperv.h
>> @@ -708,8 +708,9 @@ struct vmbus_channel_msginfo {
>>   };
>>
>>   struct vmbus_close_msg {
>> -	struct vmbus_channel_msginfo info;
> 
> It turns out that this field of struct vmbus_close_msg is never used.
> It dates back to 2011, so maybe somewhere along the way it stopped
> being used, but struct vmbus_close_msg was left unchanged.
> 
> So a better solution to the "flex-array-member-not-at-end" issue is
> to eliminate this structure entirely, and use struct
> vmbus_channel_close_channel directly in the one place where
> struct vmbus_close_msg is currently used. I've done a quick test of
> this change and I don't see any problems.
> 
> I'll submit a separate patch with my proposed change, and this
> patch can be dropped. Does that work?
Yes, please. Go for it. :)

Thanks!
-Gustavo

      reply	other threads:[~2025-08-29 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 11:44 Gustavo A. R. Silva
2025-08-29 16:07 ` Michael Kelley
2025-08-29 16:17   ` Gustavo A. R. Silva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc494864-22c9-42a6-ba3b-f64ae753ae53@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=decui@microsoft.com \
    --cc=gustavoars@kernel.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®