Skip to content

Commit e3260d9

Browse files
committed
dm raid: Annotate struct raid_set 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 raid_set. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Alasdair Kergon <[email protected]> Cc: Mike Snitzer <[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 150849c commit e3260d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/dm-raid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ struct raid_set {
254254
int mode;
255255
} journal_dev;
256256

257-
struct raid_dev dev[];
257+
struct raid_dev dev[] __counted_by(raid_disks);
258258
};
259259

260260
static void rs_config_backup(struct raid_set *rs, struct rs_layout *l)

0 commit comments

Comments
 (0)