* [PATCH] HID: core: add __counted_by_ptr to struct hid_parser
@ 2026-09-23 6:39 Bill Wendling
0 siblings, 0 replies; only message in thread
From: Bill Wendling @ 2026-09-23 6:39 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: Kees Cook, Gustavo A. R. Silva, linux-input, linux-kernel,
linux-hardening, Bill Wendling, codemender-patching+linux
In 'struct hid_parser', the 'collection_stack' pointer field is used
to store a dynamically-allocated array of collection indices. The
size of this allocated array is tracked by 'collection_stack_size'.
Annotate 'collection_stack' with the '__counted_by_ptr' attribute
referencing 'collection_stack_size'. This allows compiler hardening
features (such as KASAN and UBSAN bounds-checking) to detect potential
out-of-bounds accesses to 'collection_stack'.
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
---
include/linux/hid.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 8d17b741638c..403da4cef890 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -790,7 +790,7 @@ struct hid_parser {
struct hid_global global_stack[HID_GLOBAL_STACK_SIZE];
unsigned int global_stack_ptr;
struct hid_local local;
- unsigned int *collection_stack;
+ unsigned int *collection_stack __counted_by_ptr(collection_stack_size);
unsigned int collection_stack_ptr;
unsigned int collection_stack_size;
struct hid_device *device;
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-23 6:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 6:39 [PATCH] HID: core: add __counted_by_ptr to struct hid_parser Bill Wendling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®