When an inner packet's IP header is split across two outer packets (a runt, which RFC 9347 allows), iptfs_reassem_cont() allocates the skb for the rest but never sets its MAC header. Any packet socket on the device then pushes back toward the unset header and panics: skbuff: skb_under_panic: text:ffffffff82071ea5 len:-65455 put:-65455 skb_push+0x53/0x60 tpacket_rcv+0x91f/0xee0 netif_receive_skb_list_internal+0x49b/0x10e0 An unprivileged user can set the whole thing up (both tunnel ends and the capture in its own namespaces). With GRO on the ingress device, gro_list_prepare() reads past the head the same way, with no socket at all. Rebuild the MAC header from the outer packet. Fixes: 075694765446 ("xfrm: iptfs: handle received fragmented inner packets") Cc: stable@vger.kernel.org Signed-off-by: Andrii Tereshchenko --- v2: fold in the fixes from verification record linux/patchwork-verify-2026-12/runtime-checks/pw-15031824/, so the patch no longer depends on C1 (patchwork 15029420) landing first: - if skb->mac_len exceeds the new skb's headroom, grow the head with pskb_expand_head() or abandon the reassembly (Issue 1: standalone heap OOB write for long MAC headers); - write h_proto only when skb->mac_len >= ETH_HLEN (Issue 2: short MAC header corrupting inner IP bytes). The v1 note below the fold that this copy relies on C1 is dropped, and the AI-assistance note moved below the fold with it, out of the commit message. v1: https://lore.kernel.org/all/e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e@mid.andrii.net/ Found by an AI code review agent while testing an unlocked runt state. Validated with a shell + Python (cryptography) + C netlink reproducer, no kernel changes or fault injection; a sender without the SA's keys cannot reach it (ESP drops forged runts). Tested: the reproducer panics unmodified kernels, as root and as an unprivileged uid, and passes with the fix, with well-formed frames; KASAN and lockdep builds, panic_on_warn=1 on the fixed kernel. GRO evidence (no packet socket needed), on f0e68014f4ac: IPv6 ESP-in-UDP with runts through GRO + rx-gro-list at ingress triggers KASAN slab reports in dev_gro_receive() (read of size 8); the same traffic with runts=0 is clean, and the fixed stack forwards everything with no report. Also reproduced with the sender on one host and a KASAN victim on another, needing only CONFIG_XFRM_IPTFS (the xfrm_iptfs module, or built in); present since v6.14. A reproducer is available to the maintainers on request. The patch was written with an AI coding assistant and reviewed by the submitter. net/xfrm/xfrm_iptfs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c index 76272b0a1829..2564e1c74c78 100644 --- a/net/xfrm/xfrm_iptfs.c +++ b/net/xfrm/xfrm_iptfs.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -845,6 +846,31 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq, } xtfs->ra_newskb = newskb; + /* Rebuild the mac header from the outer packet, as + * __input_process_payload() does for the skbs it allocates; + * packet taps push back to it on receive. + */ + if (skb_mac_header_was_set(skb)) { + /* C1 grows this headroom centrally; stay safe when + * this fix lands first. + */ + if (skb->mac_len > skb_headroom(newskb) && + pskb_expand_head(newskb, skb->mac_len - + skb_headroom(newskb), 0, + GFP_ATOMIC | __GFP_NOWARN)) { + XFRM_INC_STATS(xs_net(xtfs->x), + LINUX_MIB_XFRMINBUFFERERROR); + goto abandon; + } + skb_set_mac_header(newskb, -skb->mac_len); + memcpy(skb_mac_header(newskb), skb_mac_header(skb), + skb->mac_len); + if (skb->mac_len >= ETH_HLEN) + eth_hdr(newskb)->h_proto = + (xtfs->ra_runt[0] >> 4) == 6 ? + htons(ETH_P_IPV6) : htons(ETH_P_IP); + } + /* Copy the runt data into the buffer, but leave data * pointers the same as normal non-runt case. The extra `rrem` * recopied bytes are basically cacheline free. Allows using base-commit: 23e2765f3805a334b6b6dda454df2ff7b7cb1889 -- 2.53.0