Skip to content

Commit 15fcedd

Browse files
committed
kexec: Annotate struct crash_mem 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 crash_mem. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Eric Biederman <[email protected]> Cc: [email protected] Acked-by: Baoquan He <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent bf5abc1 commit 15fcedd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/crash_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int parse_crashkernel_low(char *cmdline, unsigned long long system_ram,
9292
struct crash_mem {
9393
unsigned int max_nr_ranges;
9494
unsigned int nr_ranges;
95-
struct range ranges[];
95+
struct range ranges[] __counted_by(max_nr_ranges);
9696
};
9797

9898
extern int crash_exclude_mem_range(struct crash_mem *mem,

0 commit comments

Comments
 (0)