linux/drivers/crypto/nx
Gustavo A. R. Silva b0bfa49c03 crypto: nx - Fix packed layout in struct nx842_crypto_header
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: 1e6b251ce1 ("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>
Reviewed-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-03-27 18:52:43 +09:00
..
Kconfig crypto/nx: Register and unregister VAS interface on PowerVM 2021-06-20 21:58:58 +10:00
Makefile crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-05-24 18:12:33 +08:00
nx_csbcpb.h crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx_debugfs.c crypto: nx - Repair some kernel-doc problems 2021-03-26 20:02:36 +11:00
nx-842.c crypto: nx - fix context leak in nx842_crypto_free_ctx 2026-03-22 11:17:59 +09:00
nx-842.h crypto: nx - Fix packed layout in struct nx842_crypto_header 2026-03-27 18:52:43 +09:00
nx-aes-cbc.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-ccm.c crypto: nx - use the new scatterwalk functions 2025-03-02 15:19:43 +08:00
nx-aes-ctr.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-ecb.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-gcm.c crypto: nx - use the new scatterwalk functions 2025-03-02 15:19:43 +08:00
nx-aes-xcbc.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx-common-powernv.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nx-common-pseries.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nx-sha256.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx-sha512.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx.h crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00