]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: nx - annotate struct nx842_crypto_header with __counted_by
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 17 Mar 2026 20:18:06 +0000 (21:18 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Mar 2026 09:52:25 +0000 (18:52 +0900)
Add the __counted_by() compiler attribute to the flexible array member
'group' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/nx/nx-842.h

index f5e2c82ba8768381e8d4efa9b15f63524f112257..a04e85e9f78e37b5d5d789153037313298873d44 100644 (file)
@@ -164,7 +164,7 @@ struct nx842_crypto_header {
                __be16 ignore;          /* decompressed end bytes to ignore */
                u8 groups;              /* total groups in this header */
        );
-       struct nx842_crypto_header_group group[];
+       struct nx842_crypto_header_group group[] __counted_by(groups);
 } __packed;
 static_assert(offsetof(struct nx842_crypto_header, group) == sizeof(struct nx842_crypto_header_hdr),
              "struct member likely outside of struct_group_tagged()");