|WARNING| [RFC] net/bnxt: fix buffer overflow in TF set message helpers
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Oct 28 06:20:30 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172198
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-28
# DPDK Patch Review
## ERRORS
**Buffer overflow vulnerabilities correctly identified and fixed**
The patch correctly identifies and fixes two buffer overflow vulnerabilities:
1. **`tf_msg_set_global_cfg()`** - Line 1621: The check now uses `sizeof(req.data)` instead of the hardcoded `TF_MSG_SET_GLOBAL_CFG_DATA_SIZE` (16), which was larger than the actual 8-byte `req.data` field size. This is the correct fix.
2. **`tf_msg_set_if_tbl_entry()`** - Line 1818-1819: Adds a missing bounds check for `params->data_sz_in_bytes` against `sizeof(req.data)` before the `rte_memcpy()` at line 1846 (not shown in patch). The check is placed early in the function before session retrieval, which is appropriate for input validation.
However, there is a **critical issue with the error path**:
**Error: Missing error message in `tf_msg_set_if_tbl_entry()` bounds check**
```c
if (params->data_sz_in_bytes > sizeof(req.data))
return -EINVAL;
```
This check silently returns `-EINVAL` without logging an error message. The existing code pattern in this file (shown in the `tf_msg_set_global_cfg()` fix) uses `TFP_DRV_LOG(ERR, ...)` to report parameter validation failures. For consistency and debuggability, this check should also log an error:
```c
if (params->data_sz_in_bytes > sizeof(req.data)) {
TFP_DRV_LOG(ERR,
"%s: Invalid data size %u, max %zu\n",
tf_dir_2_str(params->dir),
params->data_sz_in_bytes,
sizeof(req.data));
return -EINVAL;
}
```
**Error: Early return skips cleanup that may be needed**
The new bounds check at line 1818-1819 is placed before `tf_session_get_session()` at line 1822. However, examining the function structure (lines 1822-1830 shown), if `tf_session_get_session()` allocates resources or acquires locks that need cleanup, placing the validation after would be more consistent with the error path handling pattern.
Looking at the shown code: session retrieval happens at line 1822, and the check at 1821 would return before session retrieval, which is safe. However, the placement is unusual compared to the `tf_msg_set_global_cfg()` pattern where validation happens after the function header comment but the exact placement relative to resource acquisition is not shown.
**Correction:** Re-reading the code, `tf_session_get_session()` is a lookup function that does not allocate resources requiring cleanup - it retrieves an existing session pointer. The early return is safe. This is not an error.
## WARNINGS
None.
## INFO
**Hardcoded constants vs. sizeof in existing code**
The patch removes `TF_MSG_SET_GLOBAL_CFG_DATA_SIZE` (16) in favor of `sizeof(req.data)`. The constant was defined at line 26 (removed in this patch) but was larger than the actual field size (8 bytes for both `req.data` and `req.mask`). Using `sizeof()` is more maintainable and catches mismatches at compile time. This is good practice.
The patch does not remove the definition of `TF_MSG_SET_GLOBAL_CFG_DATA_SIZE` from line 26, only stops using it. Consider removing the unused `#define` as well in a follow-up or this patch.
**Correction:** The patch diff shows the `#define` is at line 26 in the context (deleted line 26), but line 23 comment says "means we have to manually sync hwrm with these defines". Re-checking: the removed line is indeed line 26: `-#define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE 16`. So the patch DOES remove the incorrect constant. No issue here.
Review-Result: ERROR
More information about the test-report
mailing list