|WARNING| [v7] examples/l3fwd: fix RFC 1812 checks
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Nov 13 22:30:04 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-13
**Errors**
1. Unsigned underflow defeats the minimum-length check (`l3fwd_em.h` and `l3fwd_lpm.h`)
```c
if (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len - sizeof(struct rte_ether_hdr),
```
`m->pkt_len` is unsigned, so a frame shorter than 14 bytes wraps around to a value near `UINT32_MAX`.
That value then passes check 1 (`link_len < sizeof(struct rte_ipv4_hdr)`) and the new `link_len < total_length` check.
Before this patch, such a runt was rejected by check 1.
Now it reaches `rte_ipv4_cksum(pkt)`, which reads `ihl * 4` bytes past the end of the received data.
That is the out-of-bounds read the patch's item 5 says it prevents.
Packet length is network-controlled input.
Suggested fix: reject short frames 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, make `is_valid_ipv4_pkt()` take the full frame length and subtract the L2 header length inside it, after checking that the frame is long enough.
**Info**
2. `link_len` is the total packet length, but the checksum reads the first segment only.
`m->pkt_len` is the length across all segments.
`rte_ipv4_cksum(pkt)` reads the header from a single contiguous buffer.
For a multi-segment mbuf whose first segment is shorter than the IP header, the new length checks do not guarantee the checksum read stays inside the first segment.
Passing `m->data_len` (minus the L2 header) for the bounds part of the check would make the guard match what is actually read.
The existing callers already pass `pkt_len`, so this is largely pre-existing behaviour.
Review-Result: ERROR
More information about the test-report
mailing list