netfilter: nf_tables: Annotate struct nft_pipapo_match with __counted_by
authorKees Cook <keescook@chromium.org>
Tue, 3 Oct 2023 23:17:51 +0000 (16:17 -0700)
committerFlorian Westphal <fw@strlen.de>
Thu, 12 Oct 2023 08:28:45 +0000 (10:28 +0200)
commitd51c42cdef5f961f63e39e172e4dfdcac54acd5e
tree0c46efa293deb751721cc6f5ca4573b49d973700
parent2e1d175410972285333193837a4250a74cd472e6
netfilter: nf_tables: Annotate struct nft_pipapo_match 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 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 nft_pipapo_match.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Cc: netdev@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_set_pipapo.h