Skip to content

Commit 2aba54a

Browse files
keesrleon
authored andcommitted
IB/mthca: Annotate struct mthca_icm_table 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 mthca_icm_table. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Leon Romanovsky <leon@kernel.org> Cc: linux-rdma@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230929180431.3005464-6-keescook@chromium.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent bd8eec5 commit 2aba54a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/infiniband/hw/mthca/mthca_memfree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct mthca_icm_table {
6868
int lowmem;
6969
int coherent;
7070
struct mutex mutex;
71-
struct mthca_icm *icm[];
71+
struct mthca_icm *icm[] __counted_by(num_icm);
7272
};
7373

7474
struct mthca_icm_iter {

0 commit comments

Comments
 (0)