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.
Showing the changes to include/uapi (1 of 1 file). Show all
Unified · Split
| @@ -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 are | 9 | /* 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 */ |