* [PATCH ipsec] xfrm: iptfs: give a runt-started inner packet a MAC header
@ 2026-11-27 22:32 Andrii Tereshchenko
0 siblings, 0 replies; only message in thread
From: Andrii Tereshchenko @ 2026-11-27 22:32 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman, Christian Hopps, netdev, ipsec, linux-kernel
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.
The patch was written with an AI coding assistant and reviewed by the
submitter.
Fixes: 075694765446 ("xfrm: iptfs: handle received fragmented inner packets")
Cc: stable@vger.kernel.org
Signed-off-by: Andrii Tereshchenko <opensource@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. Depends-on
note: this copy relies on C1
([PATCH ipsec] xfrm: iptfs: reserve room for the outer MAC header in
new inner skbs, patchwork 15029420, posted 11-27) for long MAC headers.
net/xfrm/xfrm_iptfs.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 3fff835497b9..28b9fa109251 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -845,6 +845,20 @@ 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)) {
+ 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_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: 1213df0bc5993e479706c5eba5830243d778f164
--
2.53.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-27 22:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 22:32 [PATCH ipsec] xfrm: iptfs: give a runt-started inner packet a MAC header Andrii Tereshchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®