Skip to contentSkip to conversation

ip_frag: output array overflow when fragmenting mbufs over 64 KB

DPDK/other Bug 2151 [email protected] 1 participant 1 message Nov 20

lore
Share & tools
lore
#0 lore raw

https://bugs.dpdk.org/show_bug.cgi?id=2151

Bug ID: 2151
Summary: ip_frag: output array overflow when fragmenting mbufs
over 64 KB
Product: DPDK
Version: 26.11
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: major
Priority: Normal
Component: other
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Group: security

```
============================================================================
ANT-2026-KAH9I4A9  [high]  CWE-197  memory-safety
ip_frag: output array overflow when fragmenting mbufs over 64 KB
Location: lib/ip_frag/rte_ipv4_fragmentation.c:159  in
rte_ipv4_fragment_packet()
Commit:   9a45341f18a1ab47af7123e63d942b90c1b79f38
============================================================================
```

A vhost guest can make a host DPDK application that fragments its packets write past the end of the caller's pkts_out[] array. The written values are host mbuf pointers, not guest-chosen data, and the guest needs only a single Tx descriptor in the default net_vhost configuration. The result is stack or adjacent-table corruption and a crash of the host data-path process. Code execution has not been shown. Both rte_ipv4_fragment_packet() and rte_ipv6_fragment_packet() are affected, in any application that fragments received packets larger than the egress MTU based on pkt_len, as examples/ip_fragmentation does.

The only check that pkts_out[nb_pkts_out] can hold every fragment is at lib/ip_frag/rte_ipv4_fragmentation.c:158-160 (and rte_ipv6_fragmentation.c:100). It compares against (uint16_t)(pkt_in->pkt_len - header_len). The loop that follows walks the whole mbuf chain and never looks at nb_pkts_out again. A chain of 65556 bytes or more therefore passes the check on its low 16 bits. The function then stores one pointer per fragment past the array and returns a count larger than nb_pkts_out (45 for 16 slots), so the caller also reads those out-of-bounds entries. The vhost dequeue path puts no upper bound on frame length unless linear-buffer=1 is set. A remote sender can reach the same state through a separate defect: reassembly ignores a failed rte_pktmbuf_trim(). That route also needs jumbo frames, scattered Rx, and an application that reassembles before it fragments. The attached reproducer has a vhost-user guest send a 65557-byte IPv4 frame to a forwarder modelled on examples/ip_fragmentation. ASan reports a stack-buffer-overflow WRITE past frags[16] at rte_ipv4_fragmentation.c:258. On a plain gcc build, larger frames end in a "stack smashing detected" abort or SIGSEGV. The truncating check dates from 4c38e5532a07 ("ip_frag: refactor IPv4 fragmentation into a proper library").

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.