Skip to content

Commit fbd126f

Browse files
keesakpm00
authored andcommitted
gcov: annotate struct gcov_iterator 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 gcov_iterator. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Reviewed-by: Peter Oberparleiter <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Tom Rix <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 71ca5ee commit fbd126f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/gcov/fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct gcov_iterator {
9999
struct gcov_info *info;
100100
size_t size;
101101
loff_t pos;
102-
char buffer[];
102+
char buffer[] __counted_by(size);
103103
};
104104

105105
/**

0 commit comments

Comments
 (0)