Skip to content

Commit c7c4ac7

Browse files
committed
usb: gadget: f_fs: Annotate struct ffs_buffer 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 ffs_buffer. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Greg Kroah-Hartman <[email protected]> Cc: John Keeping <[email protected]> Cc: Udipto Goswami <[email protected]> Cc: Linyu Yuan <[email protected]> Cc: [email protected] Reviewed-by: "Gustavo A. R. Silva" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent d5ae1c3 commit c7c4ac7

File tree

1 file changed

+1
-1
lines changed
  • drivers/usb/gadget/function

1 file changed

+1
-1
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ struct ffs_epfile {
202202
struct ffs_buffer {
203203
size_t length;
204204
char *data;
205-
char storage[];
205+
char storage[] __counted_by(length);
206206
};
207207

208208
/* ffs_io_data structure ***************************************************/

0 commit comments

Comments
 (0)