|WARNING| [2/2] net/netvsc: fix link status not updated on host indication
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Oct 14 04:24:07 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171239
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-14
# DPDK Patch Review
## PATCH 1/2: net/netvsc: fix link speed not updated
### Errors
None.
### Warnings
None.
### Info
None.
---
## PATCH 2/2: net/netvsc: fix link status not updated on host indication
### Errors
**hn_rndis_link_alarm() - Missing check on rte_eth_linkstatus_get() return value:**
Line in `drivers/net/netvsc/hn_rndis.c`:
```c
rte_eth_linkstatus_get(dev, &old);
```
`rte_eth_linkstatus_get()` can return -EINVAL if `dev` is NULL. Although this is unlikely in the alarm callback context where `dev` came from a known-good registration, the function can fail and the code does not check. If it fails, `old` contains uninitialized data, leading to garbage comparison and potentially spurious LSC callbacks or missed updates.
Suggested fix:
```c
if (rte_eth_linkstatus_get(dev, &old) != 0)
return;
```
---
**hn_rndis_link_speed_get() - Integer overflow on offset addition:**
Line in `drivers/net/netvsc/hn_rndis.c`:
```c
if (indicate->stbuflen < sizeof(*speed) ||
ofs < sizeof(*indicate) || ofs > len ||
len - ofs < indicate->stbuflen)
return -EINVAL;
```
The bounds check `ofs > len` prevents accessing past the buffer, but the arithmetic `len - ofs` is performed with `uint32_t` operands after the check. If a malicious or corrupt `stbufoffset` causes `ofs` to be very large (but still `<= len`), then `len - ofs` underflows. The subsequent comparison `len - ofs < indicate->stbuflen` could pass when it should fail, allowing out-of-bounds read in the `memcpy()`.
The check order prevents the underflow from being reached in practice (`ofs > len` fails first), but the subtraction itself is still an underflow when `ofs` is close to `UINT32_MAX` and `len` is smaller. Reordering the checks so that the subtraction is only performed when safe, or using a form that cannot underflow, would be clearer.
Suggested fix (check `stbuflen` against the known-safe range before subtraction):
```c
if (indicate->stbuflen < sizeof(*speed) ||
ofs < sizeof(*indicate) || ofs > len ||
indicate->stbuflen > len - ofs)
return -EINVAL;
```
With this order, `ofs > len` fails before the subtraction `len - ofs` is evaluated, and when `ofs <= len`, the subtraction is safe. The compiler will compute `len - ofs` only in the branch where `ofs <= len` is known.
---
**hn_rndis_link_alarm_set() - Missing newline in log message:**
Line in `drivers/net/netvsc/hn_rndis.c`:
```c
PMD_DRV_LOG(ERR, "port %u: cannot schedule link update",
dev->data->port_id);
```
DPDK logging functions do not automatically append a newline. This message will run into the next log line. Add `\n` at the end of the format string.
Suggested fix:
```c
PMD_DRV_LOG(ERR, "port %u: cannot schedule link update\n",
dev->data->port_id);
```
---
### Warnings
None.
### Info
None.
---
## Summary
- **Patch 1/2**: Clean, correctly fixes the early return that prevented link updates when only speed changed.
- **Patch 2/2**: Three errors identified (missing return check, potential integer underflow in bounds check, missing newline in log). The core logic (saving indication state atomically, applying it in the alarm, and calling LSC only on actual change) is sound.
Review-Result: ERROR
More information about the test-report
mailing list