FAILED: patch "[PATCH] net: prevent receive header offset overflow during" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x b10c986f1769287270de248548476f6dc2275d59
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026120227-guzzler-quickness-a3af@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b10c986f1769287270de248548476f6dc2275d59 Mon Sep 17 00:00:00 2001
From: Chris J Arges <[email protected]>
Date: Wed, 18 Nov 2026 08:32:27 -0600
Subject: [PATCH] net: prevent receive header offset overflow during
decapsulation
Repeated decapsulation can leave skb->data far from skb->head while the remaining packet data is still valid. Since the skb header positions are 16-bit offsets, a later header update can truncate and make header access use unrelated bytes and eventually crash.
Limit receive headroom to 32 KiB. This is well beyond the headroom of normal packets while allowing the networking stack to pull enough headers in a single pass without overflowing 16-bit header offsets.
Tunnel decapsulation re-enters __netif_receive_skb_core(), so its check protects nested IPIP and GRE. FOU and GUE bypass receive core, so check their IPv4 and IPv6 resubmission paths too. Together, these checks prevent 16-bit header-offset truncation in cases of repeated decapsulation.
Report these rejections with the SKB_RX_HEADROOM drop reason.
include/linux/skbuff.h +1 -0
@@ -268,6 +268,7 @@ SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))#define SKB_MAX_HEAD (X ) (SKB_MAX_ORDER((X), 0))#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) +#define SKB_MAX_RX_HEADROOM (U16_MAX / 2)/* return minimum truesize of one skb containing X bytes of data */ #define SKB_TRUESIZE (X ) ((X) + \
include/net/dropreason-core.h +6 -0
@@ -128,6 +128,7 @@ FN(PSP_INPUT) \ FN(PSP_OUTPUT) \ FN(RECURSION_LIMIT) \ + FN(SKB_RX_HEADROOM) \ FNe(MAX)/**
@@ -612,6 +613,11 @@ enum skb_drop_reason {* itself. */ SKB_DROP_REASON_RECURSION_LIMIT , +/** +* @SKB_DROP_REASON_SKB_RX_HEADROOM: accumulated receive headroom +* exceeds the header-offset budget. +*/ + SKB_DROP_REASON_SKB_RX_HEADROOM,/** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen
net/core/dev.c +4 -0
@@ -6223,6 +6223,10 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,trace_netif_receive_skb (skb); orig_dev = skb->dev; +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { + drop_reason =SKB_DROP_REASON_SKB_RX_HEADROOM ; + goto drop; + }skb_reset_network_header (skb);#if !defined(CONFIG_DEBUG_NET )
net/ipv4/ip_input.c +6 -0
@@ -207,6 +207,12 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol) ret =INDIRECT_CALL_2 (ipprot->handler, tcp_v4_rcv, udp_rcv, skb);if (ret <0 ) { +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { +__IP_INC_STATS (net,IPSTATS_MIB_INDISCARDS ); +kfree_skb_reason (skb, +SKB_DROP_REASON_SKB_RX_HEADROOM ); +return ; + } protocol = -ret; goto resubmit; }
net/ipv6/ip6_input.c +4 -0
@@ -479,6 +479,10 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr, ret =INDIRECT_CALL_2 (ipprot->handler, tcp_v6_rcv, udpv6_rcv, skb);if (ret >0 ) { +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { +SKB_DR_SET (reason,SKB_RX_HEADROOM ); + goto discard; + }if (ipprot->flags &INET6_PROTO_FINAL ) {/* Not an extension header, most likely UDP * encapsulation. Use return value as nexthdr
PATCH 1/1 net: prevent receive header offset overflow during decapsulation
[ Upstream commit b10c986f1769287270de248548476f6dc2275d59 ]
Repeated decapsulation can leave skb->data far from skb->head while the remaining packet data is still valid. Since the skb header positions are 16-bit offsets, a later header update can truncate and make header access use unrelated bytes and eventually crash.
Limit receive headroom to 32 KiB. This is well beyond the headroom of normal packets while allowing the networking stack to pull enough headers in a single pass without overflowing 16-bit header offsets.
Tunnel decapsulation re-enters __netif_receive_skb_core(), so its check protects nested IPIP and GRE. FOU and GUE bypass receive core, so check their IPv4 and IPv6 resubmission paths too. Together, these checks prevent 16-bit header-offset truncation in cases of repeated decapsulation.
Report these rejections with the SKB_RX_HEADROOM drop reason.
--- include/linux/skbuff.h | 1 + include/net/dropreason-core.h | 6 ++++++ net/core/dev.c | 7 ++++++- net/ipv4/ip_input.c | 6 ++++++ net/ipv6/ip6_input.c | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-)
include/linux/skbuff.h +1 -0
@@ -267,6 +267,7 @@ SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))#define SKB_MAX_HEAD (X ) (SKB_MAX_ORDER((X), 0))#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) +#define SKB_MAX_RX_HEADROOM (U16_MAX / 2)/* return minimum truesize of one skb containing X bytes of data */ #define SKB_TRUESIZE (X ) ((X) + \
include/net/dropreason-core.h +6 -0
@@ -106,6 +106,7 @@ FN(IP_TUNNEL_ECN) \ FN(TUNNEL_TXINFO) \ FN(LOCAL_MAC) \ + FN(SKB_RX_HEADROOM) \ FNe(MAX)/**
@@ -488,6 +489,11 @@ enum skb_drop_reason {* the MAC address of the local netdev. */ SKB_DROP_REASON_LOCAL_MAC , +/** +* @SKB_DROP_REASON_SKB_RX_HEADROOM: accumulated receive headroom +* exceeds the header-offset budget. +*/ + SKB_DROP_REASON_SKB_RX_HEADROOM,/** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen
net/core/dev.c +6 -1
@@ -5661,6 +5661,7 @@ static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,static int __netif_receive_skb_core (struct sk_buff **pskb,bool pfmemalloc,struct packet_type **ppt_prev) { +enum skb_drop_reason drop_reason =SKB_DROP_REASON_UNHANDLED_PROTO ;struct packet_type *ptype, *pt_prev;rx_handler_func_t *rx_handler;struct sk_buff *skb = *pskb;
@@ -5674,6 +5675,10 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,trace_netif_receive_skb (skb); orig_dev = skb->dev; +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { + drop_reason =SKB_DROP_REASON_SKB_RX_HEADROOM ; + goto drop; + }skb_reset_network_header (skb);if (!skb_transport_header_was_set (skb))
@@ -5851,7 +5856,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,dev_core_stats_rx_dropped_inc (skb->dev); else dev_core_stats_rx_nohandler_inc(skb->dev); -kfree_skb_reason (skb,SKB_DROP_REASON_UNHANDLED_PROTO ); +kfree_skb_reason (skb, drop_reason);/* Jamal, now you will not able to escape explaining * me how you were going to use this. :-) */
net/ipv4/ip_input.c +6 -0
@@ -205,6 +205,12 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol) ret =INDIRECT_CALL_2 (ipprot->handler, tcp_v4_rcv, udp_rcv, skb);if (ret <0 ) { +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { +__IP_INC_STATS (net,IPSTATS_MIB_INDISCARDS ); +kfree_skb_reason (skb, +SKB_DROP_REASON_SKB_RX_HEADROOM ); +return ; + } protocol = -ret; goto resubmit; }
net/ipv6/ip6_input.c +4 -0
@@ -438,6 +438,10 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr, ret =INDIRECT_CALL_2 (ipprot->handler, tcp_v6_rcv, udpv6_rcv, skb);if (ret >0 ) { +if (unlikely (skb_headroom (skb) >SKB_MAX_RX_HEADROOM )) { +SKB_DR_SET (reason,SKB_RX_HEADROOM ); + goto discard; + }if (ipprot->flags &INET6_PROTO_FINAL ) {/* Not an extension header, most likely UDP * encapsulation. Use return value as nexthdr
---
base-commit: fa3ff5a9ce6f5ada4510bda0d8b891018a0be4b7
change-id: 20261202-backport-b10c986f1769287270de248548476f6dc2275d59-367a96dbaee6
Best regards,
Signature · 1 line
Chris J Arges <[email protected]>
Re: [PATCH 6.12.y] net: prevent receive header offset overflow during decapsulation
Quoted 3 lines
Limit receive headroom to 32 KiB. This is well beyond the headroom of normal packets while allowing the networking stack to pull enough headers in a single pass without overflowing 16-bit header offsets.
Queued for 6.12, 6.6 and 6.1, thanks.
Signature · 2 lines
Thanks, Sasha