Skip to content

Commit 150849c

Browse files
committed
drbd: Annotate struct fifo_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 fifo_buffer. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Philipp Reisner <[email protected]> Cc: Lars Ellenberg <[email protected]> Cc: Christoph Böhmwalder <[email protected]> Cc: Jens Axboe <[email protected]> Cc: [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 1827170 commit 150849c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/drbd/drbd_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ struct fifo_buffer {
553553
unsigned int head_index;
554554
unsigned int size;
555555
int total; /* sum of all values */
556-
int values[];
556+
int values[] __counted_by(size);
557557
};
558558
extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size);
559559

0 commit comments

Comments
 (0)