🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Duncan Austin Mon, 30 Nov 2026 14:40
[BUG] xfrm: iptfs: reassembled inner packets end with the outer frame's Ethernet header (virtio-net, 7.0 to 7.4-rc5)
#24647
Author: Duncan Austin
Date: Mon, 30 Nov 2026 14:40
181 lines
16696 bytes
When IP-TFS reassembles an inner packet that was split across two outer 
ESP packets, the last bytes of the rebuilt packet are sometimes wrong. In 
the clearest cases the final 14 bytes are the Ethernet header of the 
received outer frame: destination MAC (the receiving NIC), source MAC (the 
upstream router), ethertype 08 00. In other cases the tail is zeros or 
unrelated data. Packets that are not split are delivered intact.

- 7.0.0-44 (Ubuntu 26.04): silent corruption; XfrmInIptfsError rises by
   thousands per second under load.
- 7.3.6 (mainline build): a page_pool warning in page_to_skb, then
   "BUG: Bad page state" (refcount -1) and a crash within minutes.
- 7.4.0-rc5 (mainline build): no warnings in a short run, but the same
   14-byte Ethernet-header corruption and about 1,000 XfrmInIptfsError
   per second.

It is receive-side: the corrupted bytes only exist in the frame the 
receiving host got from its own NIC. Receivers are virtio-net guests, 
where receive buffers come from a page pool.


ENVIRONMENT

   Routers:       Ubuntu 26.04.1 LTS guests, 4 vCPU, QEMU q35 on Proxmox
                  VE 9.2 (host kernel 7.0.14, QEMU 11.0.3)
   NICs:          virtio-net, queues=4, rx-gro-hw off (to avoid a separate
                  UDP-tunnel GSO issue)
   Kernels:       7.0.0-44-generic (Ubuntu), 7.3.6-070306-generic and
                  7.4.0-070400rc5-generic (Ubuntu mainline builds)
   IKE:           strongSwan 6.x, IKEv2, PSK, aes256gcm16, Child SAs
                  mode = iptfs, replay_window = 1024
   IP-TFS:        packet_size = 0 (path MTU), dont_frag = no,
                  reorder_window = 8, drop_time = 30000, init_delay = 0
   Interfaces:    XFRM interfaces (if_id), one per tunnel, MTU 9000;
                  OSPF over them
   Outer path:    Internet, MTU 1500, native ESP (no UDP encapsulation)
   Inner traffic: VXLAN (UDP 4789) between hypervisors, carrying
                  1,500-byte VM packets, so 1,550-byte inner IP packets
   Sender TX:     single TX queue via XPS (all CPUs on tx-0), so ESP
                  leaves in sequence order; XfrmInStateSeqError stays 0

Addresses below are from our captures; we can supply full pcaps privately.


HOW TO REPRODUCE

Any traffic whose inner packets are larger than the IP-TFS outer payload 
(about 1,440 bytes on a 1,500-byte path) triggers it, because every such 
packet is split across two outer packets.

1. Two virtio-net guests (sender and receiver) with an IP-TFS tunnel
    between them, outer MTU 1500, single sender TX queue (or
    "ethtool -L <dev> combined 1") so ESP arrives in order.
2. Send TCP through the tunnel with 1,500-byte inner packets inside
    VXLAN, so each is 1,550 bytes. A sustained download of about
    650 Mbit/s was enough.
3. On the receiver, watch XfrmInIptfsError in /proc/net/xfrm_stat: it
    rises steadily (7.0: about 60,000 during one speed-test download;
    7.4-rc5: 21,358 in 20 seconds).
4. Capture the inner packets before encryption on the sender side and
    after reassembly on the receiver (tcpdump -s0 on the interfaces either
    side of the tunnel), match them by flow, IP ID and TCP sequence, and
    compare bytes.

With inner packets of 1,400 bytes or less (VM MTU 1350), throughput is 
normal and the end hosts see no damage. We have not yet measured 
XfrmInIptfsError at that size: IP-TFS can still split a packet that does 
not fit the space left in the current outer packet.


EVIDENCE

Offsets are into the VXLAN payload (VXLAN header onwards). "Before" is the 
packet as sent into the tunnel, "after" as it leaves the receiver after 
reassembly. bc:24:11:de:11:98 is the receiving router's own outer NIC; 
00:c0:89:4b:50:08 is its upstream router.

7.0.0-44: Ethernet header in the tail

   1522-byte packet, 14 bytes differ at 1508..1521 (the last 14)
     after  [1508:1522] bc 24 11 de 11 98 00 c0 89 4b 50 08 08 00
     before [1508:1522] d4 4a 97 2d b7 37 42 0d a5 3c 1c e5 46 af

In the other direction (another receiver running 7.0), damaged packets had 
16 to 38 bytes changed at the end, sometimes zeros:

     before [1484:1500] 02 64 1e 43 9a e9 de a7 0b 32 14 7a 67 f6 0e ad
     after  [1484:1500] 00 00 00 00 00 00 00 00 00 00 00 00 67 f6 0e ad

Some damaged packets had their inner TCP sequence changed as well, so 
could not be matched to any sent packet. The next hop's UDP checksum check 
caught about 9 per second (UdpInCsumErrors). Of about 19,400 matched 
packets, the rest were byte-identical apart from the normal inner TCP 
checksum fill-in.

7.3.6: page_pool warning, then bad page state

   WARNING: include/net/page_pool/helpers.h:297 at page_to_skb+0x4fb/0x5a0, 
CPU#0: swapper/0/0
     ... that boot ended (crash, auto-reboot) 43 s later; on the next
     boot, 43 s after start:
   BUG: Bad page state in process swapper/0  pfn:105844
   page: refcount:-1 mapcount:0 mapping:0000000000000000 index:0x1a3 
pfn:0x105844
   page dumped because: nonzero _refcount
   Call Trace (abridged): bad_page <- __rmqueue_pcplist <- rmqueue
     <- get_page_from_freelist <- __alloc_frozen_pages <- allocate_slab
     <- kmem_cache_alloc <- __nf_conntrack_alloc <- nf_conntrack_in
     <- ip_list_rcv   (iptfs_output_collect also on the stack)
   Modules: esp4 xfrm_user xfrm_algo xfrm_interface xfrm_iptfs
     nf_conntrack nf_tables ...

The allocation that tripped the check is the victim, not the culprit: a 
page was freed once too often earlier.

7.4.0-rc5: same corruption, no warnings

   1510-byte packet, 14 bytes differ at 1496..1509 (the last 14)
     after  [1496:1510] bc 24 11 de 11 98 00 c0 89 4b 50 08 08 00
     before [1496:1510] 18 4d db b2 bc 38 bf d6 f7 f8 03 fe 75 48
   1475-byte packet, 14 bytes differ at 1461..1474 (the last 14)
     after  [1461:1475] bc 24 11 de 11 98 00 c0 89 4b 50 08 08 00

dmesg clean, 690 Mbit/s throughput, XfrmInIptfsError +21,358 in 20 s, 
XfrmInStateSeqError 0.


ANALYSIS

The damage happens on the receiver during reassembly, and the evidence 
points at how the continuation bytes are taken from the outer frame.

- Receive side. The 14 bytes that appear are the receiver's own incoming
   frame header. The sender never had them.
- Only split packets. Damage is always at the end of a rebuilt packet,
   which is the part carried in the second outer packet. Unsplit packets
   arrive intact.
- Exactly 14 bytes, ETH_HLEN, in the clearest cases. The end of the
   copied range seems to be computed 14 bytes short, or the tail is read
   from the start of the receive buffer, where the Ethernet header sits.
   The zeros and unrelated data seen elsewhere would fit the same fault
   landing on a recycled page.
- Page sharing. iptfs_reassem_cont() can append the continuation by
   sharing fragments of the received skb (iptfs_skb_add_frags()) instead
   of copying them. On virtio-net those pages belong to the receive page
   pool. 7.3.6's page_pool warning in page_to_skb and the refcount -1
   page suggest a reference on a pool page is taken or dropped wrongly.
   On 7.0 the same mistake would show as a page recycled and refilled
   with a new frame while a rebuilt packet still points into it.

Related recent fixes in the same code that do not appear to cover this (by 
subject):

- xfrm: iptfs: propagate SKBFL_SHARED_FRAG in iptfs_skb_add_frags()
   (CVE-2026-64566)
- xfrm: iptfs: fix stack OOB read in iptfs_skb_reset_frag_walk()
- xfrm: iptfs: linearize newskb before the copy fallback in
   iptfs_reassem_cont()

WHAT WE CAN PROVIDE

We can reproduce this at will on a test router and are happy to test 
patches against 7.4-rc or net.

- Paired pcaps (before and after the tunnel, 20,000 packets each) for
   7.0 and 7.4-rc5, shared privately.
- Full dmesg and journalctl -k for both 7.3.6 boots, including the
   complete page_to_skb warning trace.
- The comparison script that matches packets across the two captures
   and reports changed byte ranges.
- Our strongSwan and charon IP-TFS configuration.

All the best,

Duncan Austin

da@citrus-it.co.uk
-- 
Citrus IT Limited | +44 (0)333 0124 007 | enquiries@citrus-it.co.uk
Rock House Farm | Green Moor | Wortley | Sheffield | S35 7DQ
Registered in England and Wales | Company number 4899123
Re: [BUG] xfrm: iptfs: reassembled inner packets end with the outer frame's Ethernet header (virtio-net, 7.0 to 7.4-rc5)
#24856
Author: Duncan Austin
Date: Mon, 30 Nov 2026 23:52
20 lines
9508 bytes
Follow-up with a controlled comparison: same receiver (second VM, 
7.0.0-44), same path and peer, only the inner test VM MTU changed.
   inner MTU 1350 (1,400-byte VXLAN, not split):
     750/650 Mbit/s down/up, XfrmInIptfsError +0 in 20 s, no damaged
     packets in the capture comparison
   inner MTU 1500 (1,550-byte VXLAN, split):
     650/8 Mbit/s down/up, XfrmInIptfsError +12,337 in 20 s, tail damage
     with the same signature, e.g. a 1426-byte packet whose last 12 bytes
     are
       11 3f 9e 8f 00 c0 89 4b 50 08 08 00
     (end of the receiving NIC's own MAC bc:24:11:3f:9e:8f, the
     upstream router's MAC, ethertype 08 00)

So on this setup the corruption is specific to inner packets that
IP-TFS splits across two outer packets.
-- 
Citrus IT Limited | +44 (0)333 0124 007 | enquiries@citrus-it.co.uk
Rock House Farm | Green Moor | Wortley | Sheffield | S35 7DQ
Registered in England and Wales | Company number 4899123
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads