public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Alison Schofield <alison.schofield@intel.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	nvdimm@lists.linux.dev, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] UAPI: ndctl / acpi: intel: Avoid multiple -Wflex-array-member-not-at-end warnings
Date: Mon, 7 Apr 2025 11:11:08 -0700	[thread overview]
Message-ID: <202504071106.3A0AF875F@keescook> (raw)
In-Reply-To: <Z65xV2TaFY32eYdp@aschofie-mobl2.lan>

On Thu, Feb 13, 2025 at 02:25:27PM -0800, Alison Schofield wrote:
> On Thu, Feb 13, 2025 at 03:29:12PM +1030, Gustavo A. R. Silva wrote:
> > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> > getting ready to enable it, globally.
> > 
> > So, in order to avoid ending up with flexible-array members in the
> > middle of other structs, we use the `__struct_group()` helper to
> > separate the flexible array from the rest of the members in the
> > flexible structure. We then use the newly created tagged `struct
> > nd_cmd_pkg_hdr` to replace the type of the objects causing trouble
> > (`pkg`) in multiple structs.
> > 
> > So, with these changes, fix the following warnings:
> > 
> > drivers/acpi/nfit/intel.c:692:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 
> One sample warning is good.
> 
> How about adding a comment on why the usage of __struct_group() here
> means this doesn't break userspace.
> 
> snip
> 
> > diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
> > index 73516e263627..34c11644d5d7 100644
> > --- a/include/uapi/linux/ndctl.h
> > +++ b/include/uapi/linux/ndctl.h
> 
> FWIW: In a patch like this where reviewers likely want to see
> the header file change first, put it first in the diff.
> (git diff.orderfile)

TIL about diff.orderfile! :) Just for my own education, what do you have
as the contents for your orderfile? Is it just simply:

*.h

?

> 
> 
> > @@ -227,12 +227,15 @@ enum ars_masks {
> >   */
> >  
> >  struct nd_cmd_pkg {
> > -	__u64   nd_family;		/* family of commands */
> > -	__u64   nd_command;
> > -	__u32   nd_size_in;		/* INPUT: size of input args */
> > -	__u32   nd_size_out;		/* INPUT: size of payload */
> > -	__u32   nd_reserved2[9];	/* reserved must be zero */
> > -	__u32   nd_fw_size;		/* OUTPUT: size fw wants to return */
> > +	/* New members MUST be added within the __struct_group() macro below. */
> > +	__struct_group(nd_cmd_pkg_hdr, __hdr, /* no attrs */,
> > +		__u64   nd_family;		/* family of commands */
> > +		__u64   nd_command;
> > +		__u32   nd_size_in;		/* INPUT: size of input args */
> > +		__u32   nd_size_out;		/* INPUT: size of payload */
> > +		__u32   nd_reserved2[9];	/* reserved must be zero */
> > +		__u32   nd_fw_size;		/* OUTPUT: size fw wants to return */
> > +	);
> >  	unsigned char nd_payload[];	/* Contents of call      */
> >  };

Gustavo, any updates on this patch? I'm skimming through patchwork to
check on stalled patches...

-- 
Kees Cook

  reply	other threads:[~2025-04-07 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13  4:59 [PATCH][next] UAPI: ndctl / acpi: intel: Avoid multiple -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-13 22:25 ` Alison Schofield
2025-04-07 18:11   ` Kees Cook [this message]
2025-04-07 19:09     ` Gustavo A. R. Silva
2025-05-06 18:37     ` Kees Cook

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=202504071106.3A0AF875F@keescook \
    --to=kees@kernel.org \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=gustavoars@kernel.org \
    --cc=ira.weiny@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=vishal.l.verma@intel.com \
    /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