|WARNING| [v7] examples/l3fwd: fix RFC 1812 checks
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Sat Nov 14 01:20:29 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172887
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-14
**Error: unsigned underflow in the link length passed to `is_valid_ipv4_pkt()`**
The new argument expression underflows when `pkt_len` is shorter than the Ethernet header. This appears in both callers.
l3fwd_em.h:
```
+ if (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len - sizeof(struct rte_ether_hdr),
```
l3fwd_lpm.h:
```
+ if (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len - sizeof(struct rte_ether_hdr),
```
- **What happens:** `m->pkt_len` is `uint32_t` and `sizeof()` is `size_t`. If `pkt_len < 14`, the subtraction wraps to a huge value. It is then truncated to `uint32_t` as nearly `UINT32_MAX` when passed as `link_len`.
- **Why it is a regression:** The old code passed the unmodified `pkt_len`, so a runt packet was rejected by check 1 (`link_len < sizeof(struct rte_ipv4_hdr)`). With the patch, such a packet passes check 1 and the new `link_len < total_length` check. `rte_ipv4_cksum()` then reads up to 60 bytes of header past the end of the received data. The `CKSUM_NONE` case also writes `hdr_checksum` there.
- **Who is exposed:** Runt frames are not filtered by every PMD (for example pcap, ring, af_packet, or virtio from a guest).
- **Suggested fix:** Guard before subtracting, for example:
```c
if (m->pkt_len < sizeof(struct rte_ether_hdr) ||
is_valid_ipv4_pkt(ipv4_hdr,
m->pkt_len - sizeof(struct rte_ether_hdr),
m->ol_flags) < 0) {
```
Alternatively, pass `m->pkt_len` and the L2 header length to `is_valid_ipv4_pkt()` and do the comparison there without subtracting.
**Info: pre-existing, `pkt_len` versus contiguous data**
This was not introduced by the patch. `link_len` is derived from `m->pkt_len`, which is the total across all segments. `rte_ipv4_cksum(pkt)` reads the header contiguously from the first segment. With scattered Rx, the length checks therefore do not guarantee the header bytes are in `data_len` of the first segment. Using `rte_pktmbuf_data_len(m)` for the header-length bound would be stricter. That could be done separately.
Review-Result: ERROR
More information about the test-report
mailing list