From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Naga Harish K S V <s.v.naga.harish.k@intel.com>,
Jerin Jacob <jerinj@marvell.com>,
Ganapati Kundapura <ganapati.kundapura@intel.com>,
Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Subject: [PATCH 7/8] eventdev/eth_rx: reject out-of-range telemetry adapter ID
Date: Fri, 5 Jun 2026 13:51:04 -0700 [thread overview]
Message-ID: <20260605205253.520196-8-stephen@networkplumber.org> (raw)
In-Reply-To: <20260605205253.520196-1-stephen@networkplumber.org>
The eventdev rx adapter code was using atoi() to parse numeric
parameters which does not handle out-of-range or extra garbage
on input. Tighten the code to only accept valid numbers.
Fixes: 814d01709328 ("eventdev/eth_rx: support telemetry")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eventdev/rte_event_eth_rx_adapter.c | 45 +++++++++++--------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 96a4a0d926..635bd6014b 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -270,8 +270,8 @@ rxa_timestamp_dynfield(struct rte_mbuf *mbuf)
event_eth_rx_timestamp_dynfield_offset, rte_mbuf_timestamp_t *);
}
-static inline int
-rxa_validate_id(uint8_t id)
+static inline bool
+rxa_validate_id(unsigned long id)
{
return id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
}
@@ -294,14 +294,14 @@ rxa_event_buf_get(struct event_eth_rx_adapter *rx_adapter, uint16_t eth_dev_id,
#define RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) do { \
if (!rxa_validate_id(id)) { \
- RTE_EDEV_LOG_ERR("Invalid eth Rx adapter id = %d", id); \
+ RTE_EDEV_LOG_ERR("Invalid eth Rx adapter id = %lu", (unsigned long)id); \
return retval; \
} \
} while (0)
#define RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(id, retval) do { \
if (!rxa_validate_id(id)) { \
- RTE_EDEV_LOG_ERR("Invalid eth Rx adapter id = %d", id); \
+ RTE_EDEV_LOG_ERR("Invalid eth Rx adapter id = %lu", (unsigned long)id); \
ret = retval; \
goto error; \
} \
@@ -316,8 +316,8 @@ rxa_event_buf_get(struct event_eth_rx_adapter *rx_adapter, uint16_t eth_dev_id,
} while (0)
#define RTE_EVENT_ETH_RX_ADAPTER_PORTID_VALID_OR_GOTO_ERR_RET(port_id, retval) do { \
- if (!rte_eth_dev_is_valid_port(port_id)) { \
- RTE_EDEV_LOG_ERR("Invalid port_id=%u", port_id); \
+ if (port_id >= RTE_MAX_ETHPORTS || !rte_eth_dev_is_valid_port(port_id)) { \
+ RTE_EDEV_LOG_ERR("Invalid port_id=%lu", (unsigned long)port_id); \
ret = retval; \
goto error; \
} \
@@ -3761,14 +3761,14 @@ handle_rxa_stats(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d)
{
- uint8_t rx_adapter_id;
+ unsigned long rx_adapter_id;
struct rte_event_eth_rx_adapter_stats rx_adptr_stats;
if (params == NULL || strlen(params) == 0 || !isdigit((unsigned char)*params))
return -1;
/* Get Rx adapter ID from parameter string */
- rx_adapter_id = atoi(params);
+ rx_adapter_id = strtoul(params, NULL, 10);
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL);
/* Get Rx adapter stats */
@@ -3802,13 +3802,13 @@ handle_rxa_stats_reset(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d __rte_unused)
{
- uint8_t rx_adapter_id;
+ unsigned long rx_adapter_id;
if (params == NULL || strlen(params) == 0 || !isdigit((unsigned char)*params))
return -1;
/* Get Rx adapter ID from parameter string */
- rx_adapter_id = atoi(params);
+ rx_adapter_id = strtoul(params, NULL, 10);
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL);
/* Reset Rx adapter stats */
@@ -3825,9 +3825,7 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d)
{
- uint8_t rx_adapter_id;
- uint16_t rx_queue_id;
- uint16_t eth_dev_id;
+ unsigned long rx_adapter_id, rx_queue_id, eth_dev_id;
int ret = -1;
char *token, *l_params, *saveptr = NULL;
struct rte_event_eth_rx_adapter_queue_conf queue_conf;
@@ -3857,7 +3855,7 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
/* Get Rx queue ID from parameter string */
rx_queue_id = strtoul(token, NULL, 10);
if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
- RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %lu", rx_queue_id);
ret = -EINVAL;
goto error;
}
@@ -3898,9 +3896,7 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d)
{
- uint8_t rx_adapter_id;
- uint16_t rx_queue_id;
- uint16_t eth_dev_id;
+ unsigned long rx_adapter_id, rx_queue_id, eth_dev_id;
int ret = -1;
char *token, *l_params, *saveptr = NULL;
struct rte_event_eth_rx_adapter_queue_stats q_stats;
@@ -3930,7 +3926,7 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
/* Get Rx queue ID from parameter string */
rx_queue_id = strtoul(token, NULL, 10);
if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
- RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %lu", rx_queue_id);
ret = -EINVAL;
goto error;
}
@@ -3970,9 +3966,7 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d __rte_unused)
{
- uint8_t rx_adapter_id;
- uint16_t rx_queue_id;
- uint16_t eth_dev_id;
+ unsigned long rx_adapter_id, rx_queue_id, eth_dev_id;
int ret = -1;
char *token, *l_params, *saveptr = NULL;
@@ -4001,7 +3995,7 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
/* Get Rx queue ID from parameter string */
rx_queue_id = strtoul(token, NULL, 10);
if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
- RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %lu", rx_queue_id);
ret = -EINVAL;
goto error;
}
@@ -4033,8 +4027,7 @@ handle_rxa_instance_get(const char *cmd __rte_unused,
struct rte_tel_data *d)
{
uint8_t instance_id;
- uint16_t rx_queue_id;
- uint16_t eth_dev_id;
+ unsigned long rx_queue_id, eth_dev_id;
int ret = -1;
char *token, *l_params, *saveptr = NULL;
@@ -4057,7 +4050,7 @@ handle_rxa_instance_get(const char *cmd __rte_unused,
/* Get Rx queue ID from parameter string */
rx_queue_id = strtoul(token, NULL, 10);
if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
- RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %lu", rx_queue_id);
ret = -EINVAL;
goto error;
}
@@ -4074,7 +4067,7 @@ handle_rxa_instance_get(const char *cmd __rte_unused,
rx_queue_id,
&instance_id)) {
RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
- " for rx_queue_id = %d", rx_queue_id);
+ " for rx_queue_id = %lu", rx_queue_id);
return -1;
}
--
2.53.0
next prev parent reply other threads:[~2026-06-05 20:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 20:50 [PATCH 0/8] telemetry: thread-safe and bounded parameter parsing Stephen Hemminger
2026-06-05 20:50 ` [PATCH 1/8] telemetry: fix thread-unsafe command parsing Stephen Hemminger
2026-06-08 1:25 ` fengchengwen
2026-06-08 7:49 ` Bruce Richardson
2026-06-05 20:50 ` [PATCH 2/8] ethdev: make telemetry parameter parsing thread-safe Stephen Hemminger
2026-06-08 1:26 ` fengchengwen
2026-06-05 20:51 ` [PATCH 3/8] dmadev: validate telemetry parameters Stephen Hemminger
2026-06-08 1:20 ` fengchengwen
2026-06-05 20:51 ` [PATCH 4/8] security: harden telemetry parameter parsing Stephen Hemminger
2026-06-05 20:51 ` [PATCH 5/8] eventdev: remove strtok from telemetry handlers Stephen Hemminger
2026-06-05 20:51 ` [PATCH 6/8] eventdev/eth_rx: fix thread-unsafe telemetry parsing Stephen Hemminger
2026-06-05 20:51 ` Stephen Hemminger [this message]
2026-06-05 20:51 ` [PATCH 8/8] eventdev/timer: reject out-of-range ID Stephen Hemminger
2026-06-06 6:08 ` [PATCH 0/8] telemetry: thread-safe and bounded parameter parsing Stephen Hemminger
2026-06-08 7:55 ` Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260605205253.520196-8-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=ganapati.kundapura@intel.com \
--cc=jay.jayatheerthan@intel.com \
--cc=jerinj@marvell.com \
--cc=s.v.naga.harish.k@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.