Files
linux/include/linux
Bill Wendling 150a04d817 compiler_types.h: Attributes: Add __counted_by_ptr macro
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]>
2026-01-17 11:00:28 -08:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-11 10:01:30 +01:00
…
2025-11-18 22:26:02 +05:30
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-12-12 12:36:44 -07:00
…
…
…
2025-12-04 07:19:26 -07:00
…
…
…
…
2025-12-09 23:29:42 -08:00
…
…
…
…
…
…
…
…
…
2025-11-21 11:21:31 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-12-13 20:04:32 +12:00
…
…
…
…
…
…
…
…
2025-12-16 00:57:29 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-23 12:30:40 +01:00
…
…
…
…
…
…
…
2025-11-20 13:43:59 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-05 23:58:20 +01:00
…
2025-11-11 10:01:30 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-27 14:24:30 -08:00
…
…
…
…
…
…
…
…
2025-11-18 17:52:54 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-11 13:18:56 +01:00
…
…
…
2025-11-28 09:21:18 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-27 14:22:31 +01:00
…
…
…
…
…
…
2025-11-20 17:57:40 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-25 10:07:42 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-24 15:08:54 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…