Skip to content

Commit a56d555

Browse files
keesIngo Molnar
authored and
Ingo Molnar
committed
perf/x86/rapl: Annotate 'struct rapl_pmus' 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 via CONFIG_UBSAN_BOUNDS=y (for array indexing) and CONFIG_FORTIFY_SOURCE=y (for strcpy/memcpy-family functions). Found with Coccinelle: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Add __counted_by for 'struct rapl_pmus'. No change in functionality intended. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e6814ec commit a56d555

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/events/rapl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct rapl_pmu {
115115
struct rapl_pmus {
116116
struct pmu pmu;
117117
unsigned int maxdie;
118-
struct rapl_pmu *pmus[];
118+
struct rapl_pmu *pmus[] __counted_by(maxdie);
119119
};
120120

121121
enum rapl_unit_quirk {

0 commit comments

Comments
 (0)