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
4 4
5#include <linux/in6.h>5#include <linux/in6.h>
6#include <linux/types.h>6#include <linux/types.h>
7#include <linux/stddef.h>
7 8
8/* All of the structures in this file may not change size as they are9/* All of the structures in this file may not change size as they are
9 * passed into the kernel from userspace via netlink sockets.10 * passed into the kernel from userspace via netlink sockets.
@@ -33,7 +34,7 @@ struct xfrm_sec_ctx { · 23 unmodified lines
33 __u8 ctx_alg;34 __u8 ctx_alg;
34 __u16 ctx_len;35 __u16 ctx_len;
35 __u32 ctx_sid;36 __u32 ctx_sid;
36 char ctx_str[];37 char ctx_str[] __counted_by(ctx_len);
37};38};
38 39
39/* Security Context Domains of Interpretation */40/* 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