Skip to content

Commit 8927e68

Browse files
keesdtor
authored andcommitted
Input: evdev - annotate struct evdev_client 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 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 for struct evdev_client. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 9660968 commit 8927e68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/input/evdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct evdev_client {
5050
bool revoked;
5151
unsigned long *evmasks[EV_CNT];
5252
unsigned int bufsize;
53-
struct input_event buffer[];
53+
struct input_event buffer[] __counted_by(bufsize);
5454
};
5555

5656
static size_t evdev_get_mask_cnt(unsigned int type)

0 commit comments

Comments
 (0)