Skip to content

Commit cfa36f8

Browse files
committed
sparc: Annotate struct cpuinfo_tree 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 cpuinfo_tree. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "David S. Miller" <[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 cba58fc commit cfa36f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/sparc/kernel/cpumap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct cpuinfo_tree {
5050

5151
/* Offsets into nodes[] for each level of the tree */
5252
struct cpuinfo_level level[CPUINFO_LVL_MAX];
53-
struct cpuinfo_node nodes[];
53+
struct cpuinfo_node nodes[] __counted_by(total_nodes);
5454
};
5555

5656

0 commit comments

Comments
 (0)