[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27d36ec8e0539c5d6bc760de7305299a2142f9f1.camel@linux.ibm.com>
Date: Thu, 04 Apr 2024 12:49:53 -0400
From: Mimi Zohar <zohar@...ux.ibm.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Roberto Sassu
<roberto.sassu@...wei.com>,
Dmitry Kasatkin <dmitry.kasatkin@...il.com>,
Eric Snowberg <eric.snowberg@...cle.com>,
Paul Moore <paul@...l-moore.com>, James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>
Cc: linux-integrity@...r.kernel.org, linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v5][next] integrity: Avoid
-Wflex-array-member-not-at-end warnings
Hi Gustavo,
On Thu, 2024-04-04 at 09:00 -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
> ready to enable it globally.
>
> There is currently an object (`hdr)` in `struct ima_max_digest_data`
> that contains a flexible structure (`struct ima_digest_data`):
>
> struct ima_max_digest_data {
> struct ima_digest_data hdr;
> u8 digest[HASH_MAX_DIGESTSIZE];
> } __packed;
>
> So, in order to avoid ending up with a flexible-array member in the
> middle of a struct, we use the `__struct_group()` helper to separate
> the flexible array from the rest of the members in the flexible
> structure:
>
> struct ima_digest_data {
> __struct_group(ima_digest_data_hdr, hdr, __packed,
>
> ... the rest of the members
>
> );
> u8 digest[];
> } __packed;
>
> And similarly for `struct evm_ima_xattr_data`.
>
> With the change described above, we can now declare an object of the
> type of the tagged `struct ima_digest_data_hdr`, without embedding the
> flexible array in the middle of another struct:
>
> struct ima_max_digest_data {
> struct ima_digest_data_hdr hdr;
> u8 digest[HASH_MAX_DIGESTSIZE];
> } __packed;
>
> And similarly for `struct evm_digest` and `struct evm_xattr`.
>
> We also use `container_of()` whenever we need to retrieve a pointer to
> the flexible structure.
>
> So, with these changes, fix the following warnings:
>
> security/integrity/evm/evm.h:64:32: warning: structure containing a flexible
> array member is not at the end of another structure [-Wflex-array-member-not-
> at-end]
> security/integrity/evm/../integrity.h:40:35: warning: structure containing a
> flexible array member is not at the end of another structure [-Wflex-array-
> member-not-at-end]
> security/integrity/evm/../integrity.h:68:32: warning: structure containing a
> flexible array member is not at the end of another structure [-Wflex-array-
> member-not-at-end]
> security/integrity/ima/../integrity.h:40:35: warning: structure containing a
> flexible array member is not at the end of another structure [-Wflex-array-
> member-not-at-end]
> security/integrity/ima/../integrity.h:68:32: warning: structure containing a
> flexible array member is not at the end of another structure [-Wflex-array-
> member-not-at-end]
> security/integrity/integrity.h:40:35: warning: structure containing a flexible
> array member is not at the end of another structure [-Wflex-array-member-not-
> at-end]
> security/integrity/integrity.h:68:32: warning: structure containing a flexible
> array member is not at the end of another structure [-Wflex-array-member-not-
> at-end]
> security/integrity/platform_certs/../integrity.h:40:35: warning: structure
> containing a flexible array member is not at the end of another structure [-
> Wflex-array-member-not-at-end]
> security/integrity/platform_certs/../integrity.h:68:32: warning: structure
> containing a flexible array member is not at the end of another structure [-
> Wflex-array-member-not-at-end]
>
> Link: https://github.com/KSPP/linux/issues/202
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Reviewed-by: Mimi Zohar <zohar@...ux.ibm.com>
Thanks, Gustavo. I already applied and tested v4, but was trying to actually
see the errors with before pushing it out.
Mimi
Powered by blists - more mailing lists