[PATCH] crypto: af_alg - Annotate struct af_alg_iv with __counted_by

Thorsten Blum posted 1 patch 2 months, 3 weeks ago
There is a newer version of this series
include/uapi/linux/if_alg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] crypto: af_alg - Annotate struct af_alg_iv with __counted_by
Posted by Thorsten Blum 2 months, 3 weeks ago
Add the __counted_by() compiler attribute to the flexible array member
'iv' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 include/uapi/linux/if_alg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/if_alg.h b/include/uapi/linux/if_alg.h
index b35871cbeed7..4f51e198ac2e 100644
--- a/include/uapi/linux/if_alg.h
+++ b/include/uapi/linux/if_alg.h
@@ -42,7 +42,7 @@ struct sockaddr_alg_new {
 
 struct af_alg_iv {
 	__u32	ivlen;
-	__u8	iv[];
+	__u8	iv[] __counted_by(ivlen);
 };
 
 /* Socket options */
-- 
2.51.1
Re: [PATCH] crypto: af_alg - Annotate struct af_alg_iv with __counted_by
Posted by Simon Horman 2 months, 2 weeks ago
On Fri, Nov 14, 2025 at 01:01:54AM +0100, Thorsten Blum wrote:
> Add the __counted_by() compiler attribute to the flexible array member
> 'iv' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Simon Horman <horms@kernel.org>