From: Thorsten Blum <thorsten.blum@linux.dev>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Haren Myneni <haren@us.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] crypto: nx - Fix packed layout in struct nx842_crypto_header
Date: Fri, 20 Mar 2026 16:06:06 +0100 [thread overview]
Message-ID: <ab1iXryB4x0YwA3w@linux.dev> (raw)
In-Reply-To: <abnmUvHzhgS9xA-m@kspp>
On Tue, Mar 17, 2026 at 05:40:02PM -0600, Gustavo A. R. Silva wrote:
> struct nx842_crypto_header is declared with the __packed attribute,
> however the fields grouped with struct_group_tagged() were not packed.
> This caused the grouped header portion of the structure to lose the
> packed layout guarantees of the containing structure.
>
> Fix this by replacing struct_group_tagged() with __struct_group(...,
> ..., __packed, ...) so the grouped fields are packed, and the original
> layout is preserved, restoring the intended packed layout of the
> structure.
>
> Before changes:
> struct nx842_crypto_header {
> union {
> struct {
> __be16 magic; /* 0 2 */
> __be16 ignore; /* 2 2 */
> u8 groups; /* 4 1 */
> }; /* 0 6 */
> struct nx842_crypto_header_hdr hdr; /* 0 6 */
> }; /* 0 6 */
> struct nx842_crypto_header_group group[]; /* 6 0 */
>
> /* size: 6, cachelines: 1, members: 2 */
> /* last cacheline: 6 bytes */
> } __attribute__((__packed__));
>
> After changes:
> struct nx842_crypto_header {
> union {
> struct {
> __be16 magic; /* 0 2 */
> __be16 ignore; /* 2 2 */
> u8 groups; /* 4 1 */
> } __attribute__((__packed__)); /* 0 5 */
> struct nx842_crypto_header_hdr hdr; /* 0 5 */
> }; /* 0 5 */
> struct nx842_crypto_header_group group[]; /* 5 0 */
>
> /* size: 5, cachelines: 1, members: 2 */
> /* last cacheline: 5 bytes */
> } __attribute__((__packed__));
>
> Fixes: 1e6b251ce175 ("crypto: nx - Avoid -Wflex-array-member-not-at-end warning")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> drivers/crypto/nx/nx-842.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Thorsten Blum <thorsten.blum@linux.dev>
next prev parent reply other threads:[~2026-03-20 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 23:40 [PATCH] crypto: nx - Fix packed layout in struct nx842_crypto_header Gustavo A. R. Silva
2026-03-20 15:06 ` Thorsten Blum [this message]
2026-03-27 10:06 ` Herbert Xu
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=ab1iXryB4x0YwA3w@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=gustavoars@kernel.org \
--cc=haren@us.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.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