lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <67e55ac4dfa2e_13cb29410@dwillia2-mobl3.amr.corp.intel.com.notmuch>
Date: Thu, 27 Mar 2025 10:03:48 -0400
From: Dan Williams <dan.j.williams@...el.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>, Alison Schofield
	<alison.schofield@...el.com>, Dan Williams <dan.j.williams@...el.com>,
	"Vishal Verma" <vishal.l.verma@...el.com>, Dave Jiang <dave.jiang@...el.com>,
	"Ira Weiny" <ira.weiny@...el.com>, "Rafael J. Wysocki" <rafael@...nel.org>,
	"Len Brown" <lenb@...nel.org>
CC: <nvdimm@...ts.linux.dev>, <linux-acpi@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, "Gustavo A. R. Silva"
	<gustavoars@...nel.org>, <linux-hardening@...r.kernel.org>
Subject: Re: [PATCH v2][next] acpi: nfit: intel: Avoid multiple
 -Wflex-array-member-not-at-end warnings

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.
> 
> Use the `DEFINE_RAW_FLEX()` helper for on-stack definitions of
> a flexible structure where the size of the flexible-array member
> is known at compile-time, and refactor the rest of the code,
> accordingly.
> 
> So, with these changes, fix a dozen of 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]
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> ---
> Changes in v2:
>  - Use DEFINE_RAW_FLEX() instead of __struct_group().
> 
> v1:
>  - Link: https://lore.kernel.org/linux-hardening/Z618ILbAR8YAvTkd@kspp/
> 
>  drivers/acpi/nfit/intel.c | 388 ++++++++++++++++++--------------------
>  1 file changed, 179 insertions(+), 209 deletions(-)
> 
> diff --git a/drivers/acpi/nfit/intel.c b/drivers/acpi/nfit/intel.c
> index 3902759abcba..114d5b3bb39b 100644
> --- a/drivers/acpi/nfit/intel.c
> +++ b/drivers/acpi/nfit/intel.c
> @@ -55,21 +55,17 @@ static unsigned long intel_security_flags(struct nvdimm *nvdimm,
>  {
>  	struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
>  	unsigned long security_flags = 0;
> -	struct {
> -		struct nd_cmd_pkg pkg;
> -		struct nd_intel_get_security_state cmd;
> -	} nd_cmd = {
> -		.pkg = {
> -			.nd_command = NVDIMM_INTEL_GET_SECURITY_STATE,
> -			.nd_family = NVDIMM_FAMILY_INTEL,
> -			.nd_size_out =
> -				sizeof(struct nd_intel_get_security_state),
> -			.nd_fw_size =
> -				sizeof(struct nd_intel_get_security_state),
> -		},
> -	};
> +	DEFINE_RAW_FLEX(struct nd_cmd_pkg, nd_cmd, nd_payload,
> +			sizeof(struct nd_intel_get_security_state));
> +	struct nd_intel_get_security_state *cmd =
> +			(struct nd_intel_get_security_state *)nd_cmd->nd_payload;
>  	int rc;
>  
> +	nd_cmd->nd_command = NVDIMM_INTEL_GET_SECURITY_STATE;
> +	nd_cmd->nd_family = NVDIMM_FAMILY_INTEL;
> +	nd_cmd->nd_size_out = sizeof(struct nd_intel_get_security_state);
> +	nd_cmd->nd_fw_size = sizeof(struct nd_intel_get_security_state);

Can this keep the C99 init-style with something like (untested):

_DEFINE_FLEX(struct nd_cmd_pkg, nd_cmd, nd_payload,
             sizeof(struct nd_intel_get_security_state), {
		.pkg = {
		        .nd_command = NVDIMM_INTEL_GET_SECURITY_STATE,
		        .nd_family = NVDIMM_FAMILY_INTEL,
		        .nd_size_out =
		                sizeof(struct nd_intel_get_security_state),
		        .nd_fw_size =
		                sizeof(struct nd_intel_get_security_state),
		},
	});
	

?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ