History

xfrm: Annotate struct xfrm_sec_ctx 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 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 xfrm_sec_ctx.

Kees Cook committed 3 years ago

Commit 1d495f11 parent 5fa47041 file · +2 −1Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/xfrm.h+2−1
@@ -4,6 +4,7 @@ · 3 unmodified lines
44
55 #include <linux/in6.h>
66 #include <linux/types.h>
7+#include <linux/stddef.h>
78
89 /* All of the structures in this file may not change size as they are
910 * passed into the kernel from userspace via netlink sockets.
@@ -33,7 +34,7 @@ struct xfrm_sec_ctx { · 23 unmodified lines
3334 __u8 ctx_alg;
3435 __u16 ctx_len;
3536 __u32 ctx_sid;
36− char ctx_str[];
37+ char ctx_str[] __counted_by(ctx_len);
3738 };
3839
3940 /* Security Context Domains of Interpretation */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t