summaryrefslogtreecommitdiff
path: root/include/uapi
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2024-02-17 02:27:44 +0300
committerDavid S. Miller <davem@davemloft.net>2024-02-19 13:58:24 +0300
commit1e63e5a813fa6203d7430af51d6bffb728525015 (patch)
tree9b2f81133ae9e0844a65f6bc71d03a8b7db7e35b /include/uapi
parentda4a154ca262eec77b0a07ba1a2a00c91b2b7677 (diff)
downloadlinux-1e63e5a813fa6203d7430af51d6bffb728525015.tar.xz
net: sched: Annotate struct tc_pedit with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct tc_pedit. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier. Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/linux/tc_act/tc_pedit.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/uapi/linux/tc_act/tc_pedit.h b/include/uapi/linux/tc_act/tc_pedit.h
index f3e61b04fa01..f5cab7fc96ab 100644
--- a/include/uapi/linux/tc_act/tc_pedit.h
+++ b/include/uapi/linux/tc_act/tc_pedit.h
@@ -62,7 +62,7 @@ struct tc_pedit_sel {
tc_gen;
unsigned char nkeys;
unsigned char flags;
- struct tc_pedit_key keys[0];
+ struct tc_pedit_key keys[] __counted_by(nkeys);
};
#define tc_pedit tc_pedit_sel