From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Ilya Maximets <i.maximets@ovn.org>,
Edward Cree <ecree@solarflare.com>,
Edward Cree <ecree.xilinx@gmail.com>,
Julius Bairaktaris <julius@bairaktaris.de>,
netdev@vger.kernel.org
Subject: [PATCH net] ip_tunnel: clear inner_protocol on decapsulation
Date: Sat, 5 Dec 2026 17:19:17 +0900 [thread overview]
Message-ID: <179643988093.2222342.18243841781566981638@gmail.com> (raw)
iptunnel_handle_offloads() records the inner headers when a packet is
encapsulated. For a non-GSO skb without CHECKSUM_PARTIAL, it then clears
skb->encapsulation so that another encapsulation replaces that record.
After nested IPIP packets are decapsulated, iptunnel_pull_offloads()
clears skb->encapsulation but leaves the most recent inner header record
intact. The recorded inner_network_header can then precede skb->data.
If MPLS is pushed, skb_mpls_push() sees inner_protocol still set and
retains the stale offset. OVS fragmentation later uses the negative
network offset as an unsigned copy length:
BUG: KASAN: slab-out-of-bounds in prepare_frag
Read of size 4294967294 at addr ff110000151ab08e by task test/116
Call Trace:
__asan_memcpy
prepare_frag
ovs_fragment
do_execute_actions
ovs_execute_actions
Clear inner_protocol when removing tunnel offload state. This makes the
old offsets inactive until a later encapsulation records current inner
headers. Doing this in iptunnel_pull_offloads() also covers the other
tunnel decapsulation paths which share the helper.
Fixes: 179bc67f69b6 ("net: local checksum offload for encapsulation")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/netdev/179638227378.3146.17732161383387547386@kernel.org/
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
Sashiko found this path while reviewing the MPLS fix for the same
ovs_fragment() symptom:
https://lore.kernel.org/netdev/179607412883.627473.3063198838105400446@gmail.com/
That patch clears the stale inner protocol where mpls_forward() pops the
last label; this one fixes the tunnel decapsulation source.
A pending net-next series observes the same stale marker in a separate
XFRM path and handles it at xfrm_output():
https://lore.kernel.org/all/1b35c02798f3e7c08bf0dda52cc2078161fa85e4.1796423663.git.julius@bairaktaris.de/
A reproducer is available on request.
Tested with KASAN in KVM on net. The unpatched kernel triggered the
prepare_frag() out-of-bounds read; the patched kernel completed cleanly.
Plain IPIP and GRE traffic passed on both kernels.
include/net/ip_tunnels.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5cccf4c0e691..1cc0b26556c4 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -670,6 +670,7 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb)
}
skb->encapsulation = 0;
+ skb->inner_protocol = 0;
return 0;
}
--
2.43.0
reply other threads:[~2026-12-05 8:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179643988093.2222342.18243841781566981638@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=ecree.xilinx@gmail.com \
--cc=ecree@solarflare.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=idosch@nvidia.com \
--cc=julius@bairaktaris.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox