scsi: target: tcmu: Annotate struct tcmu_tmr with __counted_by
Subsystems (3)
PATCH 1/1 scsi: target: tcmu: Annotate struct tcmu_tmr 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 tcmu_tmr.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/target/target_core_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_user.c +1 -1
@@ -201,7 +201,7 @@ struct tcmu_tmr {uint8_t tmr_type;uint32_t tmr_cmd_cnt; -int16_t tmr_cmd_ids[]; + int16_t tmr_cmd_ids[] __counted_by(tmr_cmd_cnt); };/*
Signature · 1 line
2.34.1
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structtcmu_tmr.
Quoted 7 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Bodo Stroesser <[email protected]>Cc "Martin K. Petersen" <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 17 lines
--- drivers/target/target_core_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/target/target_core_user.c +1
-1@@ -201,7 +201,7 @@ struct tcmu_tmr {uint8_t tmr_type;uint32_t tmr_cmd_cnt; -int16_t tmr_cmd_ids[]; + int16_t tmr_cmd_ids[] __counted_by(tmr_cmd_cnt); };/*
Quoted 24 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structtcmu_tmr.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Bodo Stroesser <[email protected]>Cc "Martin K. Petersen" <[email protected]>Signed-off-by Kees Cook <[email protected]>--- drivers/target/target_core_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/target/target_core_user.c +0
-0
drivers/target/target_core_user.c struct tcmu_tmr { · line 207
Quoted 8 lines
drivers/target/target_core_user.c +1
-1@@ -201,7 +201,7 @@ struct tcmu_tmr {uint8_t tmr_type;uint32_t tmr_cmd_cnt; -int16_t tmr_cmd_ids[]; + int16_t tmr_cmd_ids[] __counted_by(tmr_cmd_cnt); };/*
Thank you,
Bodo
Martin K. Petersen
AppliedKees,
Quoted 5 lines
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).
Applied to 6.7/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 9 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structtcmu_tmr.[...]
Applied to 6.7/scsi-queue, thanks!
[1/1] scsi: target: tcmu: Annotate struct tcmu_tmr with __counted_by
https://git.kernel.org/mkp/scsi/c/caf22c969ed1
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering