Merge branch 'batch-1-annotate-structs-with-__counted_by'
authorJakub Kicinski <kuba@kernel.org>
Mon, 2 Oct 2023 18:25:03 +0000 (11:25 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 2 Oct 2023 18:25:04 +0000 (11:25 -0700)
commit6d6e40ec48ca7195dceba681551dd92dc197b5a2
treedf12ae00ddbab5330954ed7d433965f2dacecd74
parent436e5f758d6fbc2c5903d59f2cf9bb753ec77d9e
parent0d01cfe5aaafdff82df0381295620e58db29d0a8
Merge branch 'batch-1-annotate-structs-with-__counted_by'

Kees Cook says:

====================
Batch 1: Annotate structs with __counted_by

This is the batch 1 of patches touching netdev for preparing 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 to structs that would
benefit from the annotation.

Since the element count member must be set before accessing the annotated
flexible array member, some patches also move the member's initialization
earlier. (These are noted in the individual patches.)

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
====================

Link: https://lore.kernel.org/r/20230922172449.work.906-kees@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>