|SUCCESS| [v2] net/af_packet: fix qpairs argument upper bound check
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu Jun 4 02:09:06 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164905
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-04
Commit: ccd37d341e8d ("net/af_packet: remove queue number limitation")
Author: Denis Sergeev <denserg.edu at gmail.com>
[PATCH v2] net/af_packet: fix qpairs argument upper bound check
The patch replaces atoi() with strtoul() for parsing the qpairs vdev
argument and adds validation to reject invalid input including negative
values, trailing garbage, and values outside valid range.
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index 8303ff5ca9..b7758a5c75 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -1168,13 +1168,20 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
> for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
> pair = &kvlist->pairs[k_idx];
> if (strstr(pair->key, ETH_AF_PACKET_NUM_Q_ARG) != NULL) {
> - qpairs = atoi(pair->value);
> - if (qpairs < 1) {
> + char *endptr;
> + unsigned long num;
> +
> + errno = 0;
> + num = strtoul(pair->value, &endptr, 10);
> + if (errno != 0 || endptr == pair->value ||
> + *endptr != '\0' || pair->value[0] == '-' ||
Does this correctly handle input like " -1" or other whitespace-prefixed
negative values? The strtoul() function skips leading whitespace, so
pair->value[0] checking for '-' won't catch cases where whitespace
precedes the minus sign.
> + num < 1 || num > RTE_MAX_QUEUES_PER_PORT) {
> PMD_LOG(ERR,
> "%s: invalid qpairs value",
> name);
> return -1;
> }
> + qpairs = num;
Does this code properly handle the case where strtoul() returns a value
that exceeds UINT_MAX? The num variable is unsigned long, but qpairs
appears to be a smaller unsigned type. Can this assignment silently
truncate on platforms where unsigned long is larger than the qpairs type?
> continue;
> }
> if (strstr(pair->key, ETH_AF_PACKET_BLOCKSIZE_ARG) != NULL) {
More information about the test-report
mailing list