* [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs
@ 2026-12-04 5:12 Kyuwon Cho
2026-12-05 5:54 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-12-04 5:12 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, Christian Hopps, netdev, ipsec
iptfs_alloc_skb() leaves the MAC header unset. When reassembly completes,
iptfs_complete_inner_skb() sends the inner skb through gro_cells_receive()
without initializing it. An AF_PACKET listener then derives a large push
length from the unset header and trips skb_under_panic():
kernel BUG at net/core/skbuff.c:215!
RIP: 0010:skb_panic (net/core/skbuff.c:215)
Call Trace:
<IRQ>
skb_push.cold (net/core/skbuff.c:225 net/core/skbuff.c:2680)
packet_rcv (net/packet/af_packet.c:2195)
__netif_receive_skb_core.constprop.0
(net/core/dev.c:2581 net/core/dev.c:6397)
gro_cell_poll (net/core/gro_cells.c:79)
Reset the MAC header to the start of the inner packet when it is unset.
Preserve a valid L2 header when the receive path rebuilt one from the outer
skb.
Fixes: 6c82d2433671 ("xfrm: iptfs: add basic receive packet (tunnel egress) handling")
Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
---
This issue was found by an LLM-guided test generator used in our research prototype.
A reproducer is available on request.
net/xfrm/xfrm_iptfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 76272b0a1829..22f83e25a86e 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -665,6 +665,8 @@ static u32 __iptfs_iplen(u8 *data)
*/
static void iptfs_complete_inner_skb(struct xfrm_state *x, struct sk_buff *skb)
{
+ if (!skb_mac_header_was_set(skb))
+ skb_reset_mac_header(skb);
skb_reset_network_header(skb);
/* The packet is going back through gro_cells_receive no need to
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs
2026-12-04 5:12 [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs Kyuwon Cho
@ 2026-12-05 5:54 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 5:54 UTC (permalink / raw)
To: kyuwon.cho
Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, willemb,
horms, chopps, netdev, ipsec
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The fix gives runt-reassembled inner packets a zero-length L2
header on an Ethernet device, which is inconsistent with the other…
- [Low] The commit message understates the impact and leaves out the
trigger.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the commit
message relies on it ("Preserve a valid L2 header when the receive…
--
xfrm: iptfs: initialize unset MAC headers on inner skbs
When an IPTFS inner skb never had its MAC header set,
iptfs_complete_inner_skb() now resets it to the start of the inner
packet. This avoids an skb_under_panic() in packet_rcv(). A MAC header
that was already rebuilt from the outer skb is kept.
> iptfs_alloc_skb() leaves the MAC header unset. When reassembly completes,
> iptfs_complete_inner_skb() sends the inner skb through gro_cells_receive()
> without initializing it. An AF_PACKET listener then derives a large push
> length from the unset header and trips skb_under_panic():
[Severity: Low]
Could the commit message say where the unset header comes from and who
can trigger it?
The skb with no MAC header comes from the runt branch of
iptfs_reassem_cont():
net/xfrm/xfrm_iptfs.c:iptfs_reassem_cont() {
...
/* For the runt case we don't attempt sharing currently. NOTE:
* Currently, this IPTFS implementation will not create runts.
*/
newskb = iptfs_alloc_skb(skb, ipremain, false);
...
}
No L2 header is rebuilt before iptfs_complete_inner_skb() runs. The
same thing happens in __input_process_payload() when the outer skb had
no MAC header.
The comment only says the Linux sender does not create runts. A remote
IPTFS peer can still create one by ending a payload with fewer than 4
(IPv4) or 6 (IPv6) bytes of an inner packet.
GRO also reads the unset header, before any packet socket sees the
packet:
xfrm_input(skb, 0, 0, -2)
gro_cells_receive()
gro_cell_poll()
napi_gro_receive()
dev_gro_receive()
gro_list_prepare()
compare_ether_header(skb_mac_header(p), skb_mac_header(skb))
On an Ethernet device this reads 14 bytes at head + 0xffff. That
happens whenever a held packet in the same bucket has the same raw
hash, and every skb from iptfs_alloc_skb() has hash 0.
The code change covers this case too. The message does not mention
that a remote peer can trigger an out-of-bounds read in GRO without
any packet socket. Would it help stable and security triage to say so?
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> index 76272b0a18296..22f83e25a86ef 100644
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
> @@ -665,6 +665,8 @@ static u32 __iptfs_iplen(u8 *data)
> */
> static void iptfs_complete_inner_skb(struct xfrm_state *x, struct sk_buff *skb)
> {
> + if (!skb_mac_header_was_set(skb))
> + skb_reset_mac_header(skb);
[Severity: Medium]
Does this give runt-reassembled packets a zero-length L2 header on an
Ethernet device, unlike the other inner-skb paths?
In __input_process_payload(), newly allocated inner skbs get the outer
L2 header rebuilt:
net/xfrm/xfrm_iptfs.c:__input_process_payload() {
...
if (old_mac) {
/* rebuild the mac header */
skb_set_mac_header(skb, -first_skb->mac_len);
memcpy(skb_mac_header(skb), old_mac, first_skb->mac_len);
eth_hdr(skb)->h_proto = skb->protocol;
}
...
}
The reuse branch there also calls skb_mac_header_rebuild(). The runt
branch of iptfs_reassem_cont() never copies the outer L2 header, even
though the outer skb it holds has a valid one:
newskb = iptfs_alloc_skb(skb, ipremain, false);
With this change that skb ends up with mac_header == data.
__netif_receive_skb_core() then computes mac_len = 0. skb->dev, which
iptfs_alloc_skb() copied from the outer packet, is still an Ethernet
device with header_ops.
So the same inner flow arrives with either a full Ethernet header or
none at all, depending only on whether its first fragment was a runt.
In packet_rcv() and tpacket_rcv(), dev_has_header(dev) is true, so this
pushes 0 bytes:
skb_push(skb, skb->data - skb_mac_header(skb));
SOCK_RAW captures would then show the IP header as an Ethernet frame.
eth_header_parse() would report IP header bytes 6-11 as the source MAC.
Three other users would also see a missing or bogus L2 header:
- tc flower ETH_ADDRS matching
- generic XDP
- mirred ingress-to-egress redirect, which pushes mac_len bytes
Could the runt path rebuild the outer L2 header the way
__input_process_payload() does? The reset to skb->data would then only
be a fallback for outer skbs that really have no MAC header.
[Severity: High]
This isn't a bug introduced by this patch, but the commit message
relies on it:
Preserve a valid L2 header when the receive path rebuilt one from the outer
skb.
Is the header rebuilt in the alloc branch of __input_process_payload()
always valid? That branch runs whenever old_mac is non-NULL:
old_mac = skb_mac_header_was_set(skb) ? skb_mac_header(skb) : NULL;
It then stores h_proto without checking first_skb->mac_len:
skb_set_mac_header(skb, -first_skb->mac_len);
memcpy(skb_mac_header(skb), old_mac, first_skb->mac_len);
eth_hdr(skb)->h_proto = skb->protocol;
Other code guards the same store with "if (skb->mac_len)": the reuse
branch in the same function, and xfrm4_remove_tunnel_encap() and
xfrm6_remove_tunnel_encap() in net/xfrm/xfrm_input.c.
Two receive paths set the MAC header without an L2 header:
- PPP: ppp_receive_nonmp_frame() calls skb_reset_mac_header() and
then netif_rx()
- sit: ipip6_rcv() calls skb_reset_mac_header()
For an outer ESP packet on either path, skb_reset_mac_len() in
__netif_receive_skb_core() gives mac_len = 0 with the MAC header set.
In that case the MAC header lands at skb->data, the memcpy copies 0
bytes, and the h_proto store overwrites bytes 12-13 of the newly copied
inner IP header.
For IPv4 those bytes are the upper half of saddr, so the header
checksum fails in ip_rcv_core(). For IPv6 they are saddr bytes 4-5,
which become 0x86DD, so the TCP, UDP and ICMPv6 pseudo-header checksums
fail. SCTP has no pseudo-header in its CRC32c, so SCTP packets would be
delivered with a rewritten source address.
This affects every inner packet that does not take the reuse branch:
every packet after the first in an aggregated outer packet, plus any
first packet that does not meet the reuse conditions. Would IPTFS over
PPP, PPPoE, L2TP or sit lose most decapsulated traffic?
The new check keeps any MAC header that is already set, so these
corrupted packets are passed on unchanged.
> skb_reset_network_header(skb);
>
> /* The packet is going back through gro_cells_receive no need to
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179633878834.538813.3134233076431912228%40skku.edu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 5:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 5:12 [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs Kyuwon Cho
2026-12-05 5:54 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox