* [PATCH net] ip_tunnel: clear inner_protocol on decapsulation
@ 2026-12-05 8:19 Kyuwon Cho
0 siblings, 0 replies; only message in thread
From: Kyuwon Cho @ 2026-12-05 8:19 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Ido Schimmel, Willem de Bruijn, Simon Horman,
Ilya Maximets, Edward Cree, Edward Cree, Julius Bairaktaris,
netdev
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-05 8:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 8:19 [PATCH net] ip_tunnel: clear inner_protocol on decapsulation Kyuwon Cho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox