[PATCH v2 2/2] net/ipv4: Annotate imsf_slist_flex with __counted_by(imsf_numsrc)

From: Kees Cook
Date: Tue Feb 13 2024 - 18:42:38 EST


The size of the imsf_slist_flex member is determined by imsf_numsrc, so
annotate it as such.

Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Cc: linux-hardening@xxxxxxxxxxxxxxx
Acked-by: Jakub Kicinski <kuba@xxxxxxxxxx>
Reviewed-by: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx>
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
include/uapi/linux/in.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index e682ab628dfa..2f0c4d40bc7b 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -199,7 +199,8 @@ struct ip_msfilter {
__u32 imsf_numsrc;
union {
__be32 imsf_slist[1];
- __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
+ __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex,
+ __counted_by(imsf_numsrc));
};
};

--
2.34.1