summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-11-20 16:31:49 -0800
committerDavid S. Miller <davem@davemloft.net>2021-11-22 15:13:54 +0000
commit03f61041c17914355dde7261be9ccdc821ddd454 (patch)
treebd95497df8f59b9729f69d97ac8092e48e0523c9 /include
parentfba84957e2e2e201cf4e352efe0c7cac0fbb5d5d (diff)
skbuff: Switch structure bounds to struct_group()
In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Replace the existing empty member position markers "headers_start" and "headers_end" with a struct_group(). This will allow memcpy() and sizeof() to more easily reason about sizes, and improve readability. "pahole" shows no size nor member offset changes to struct sk_buff. "objdump -d" shows no object code changes (outside of WARNs affected by source line number changes). Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> # drivers/net/wireguard/* Link: https://lore.kernel.org/lkml/20210728035006.GD35706@embeddedor Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/skbuff.h10
1 files changed, 3 insertions, 7 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c7889afe0d0d..eba256af64a5 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -811,12 +811,10 @@ struct sk_buff {
__u8 active_extensions;
#endif
- /* fields enclosed in headers_start/headers_end are copied
+ /* Fields enclosed in headers group are copied
* using a single memcpy() in __copy_skb_header()
*/
- /* private: */
- __u32 headers_start[0];
- /* public: */
+ struct_group(headers,
/* private: */
__u8 __pkt_type_offset[0];
@@ -921,9 +919,7 @@ struct sk_buff {
u64 kcov_handle;
#endif
- /* private: */
- __u32 headers_end[0];
- /* public: */
+ ); /* end headers group */
/* These elements must be at the end, see alloc_skb() for details. */
sk_buff_data_t tail;