Skip to content

Commit 2d26302

Browse files
committed
afs: Annotate struct afs_addr_list 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 afs_addr_list. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: David Howells <[email protected]> Cc: Marc Dionne <[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 aade153 commit 2d26302

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/afs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct afs_addr_list {
8787
enum dns_lookup_status status:8;
8888
unsigned long failed; /* Mask of addrs that failed locally/ICMP */
8989
unsigned long responded; /* Mask of addrs that responded */
90-
struct sockaddr_rxrpc addrs[];
90+
struct sockaddr_rxrpc addrs[] __counted_by(max_addrs);
9191
#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
9292
};
9393

0 commit comments

Comments
 (0)