Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: Annotate struct ff_device 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 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 ff_device.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20231006201739.work.350-kees@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Kees Cook and committed by
Dmitry Torokhov
787650cc 68ede283

+1 -1
+1 -1
include/linux/input.h
··· 562 562 563 563 int max_effects; 564 564 struct ff_effect *effects; 565 - struct file *effect_owners[]; 565 + struct file *effect_owners[] __counted_by(max_effects); 566 566 }; 567 567 568 568 int input_ff_create(struct input_dev *dev, unsigned int max_effects);