mirror of
https://github.com/torvalds/linux.git
synced 2026-11-23 23:11:40 +00:00
Introduce __counted_by_ptr(), which works like __counted_by(), but for
pointer struct members.
struct foo {
int a, b, c;
char *buffer __counted_by_ptr(bytes);
short nr_bars;
struct bar *bars __counted_by_ptr(nr_bars);
size_t bytes;
};
Because "counted_by" can only be applied to pointer members in very
recent compiler versions, its application ends up needing to be distinct
from flexibe array "counted_by" annotations, hence a separate macro.
This is a reworking of Kees' previous patch [1].
Link: https://lore.kernel.org/all/[email protected]/ [1]
Co-developed-by: Kees Cook <[email protected]>
Signed-off-by: Bill Wendling <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Kees Cook <[email protected]>