gpiolib: cdev: Annotate struct linereq with __counted_by()
PATCH 1/1 gpiolib: cdev: Annotate struct linereq 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).
--- drivers/gpio/gpiolib-cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-cdev.c +1 -1
@@ -572,7 +572,7 @@ struct linereq { DECLARE_KFIFO_PTR(events, struct gpio_v2_line_event);atomic_t seqno;struct mutex config_mutex; -struct line lines[]; + struct line lines[] __counted_by(num_lines); };#define GPIO_V2_LINE_BIAS_FLAGS \
Signature · 1 line
2.40.0.1.gaa8946217a0b
Quoted 4 lines · Andy Shevchenko
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS
(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).
Kees' patch is better, please ignore this one.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS
(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).Kees' patch is better, please ignore this one.
Oh! I didn't get CCed so I didn't know you'd sent this. :)
Thanks for taking the initiative on this, though! (But, yes, initialization order matters.)
Signature · 1 line
Kees Cook