Skip to content

Commit ea0b0bc

Browse files
keesmcgrof
authored andcommitted
module: Annotate struct module_notes_attrs 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 module_notes_attrs. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Luis Chamberlain <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent fd06da7 commit ea0b0bc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/module/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void remove_sect_attrs(struct module *mod)
143143
struct module_notes_attrs {
144144
struct kobject *dir;
145145
unsigned int notes;
146-
struct bin_attribute attrs[];
146+
struct bin_attribute attrs[] __counted_by(notes);
147147
};
148148

149149
static ssize_t module_notes_read(struct file *filp, struct kobject *kobj,

0 commit comments

Comments
 (0)