DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Jiawen Wu <jiawenwu@trustnetic.com>,
	Zaiyu Wang <zaiyuwang@trustnetic.com>
Subject: [PATCH] net/txgbe: validate numeric devargs
Date: Wed,  9 Sep 2026 13:40:52 -0700	[thread overview]
Message-ID: <20260909204052.867168-1-stephen@networkplumber.org> (raw)

Be more careful about validating devargs numeric values.
Don't silently truncate to 16 bits, and check for empty
string or trailing garbage.

Fixes: f611dada1af8 ("net/txgbe: update link setup process of backplane NICs")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_ethdev.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 111843023d..0734a1c63c 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -450,15 +450,21 @@ static int
 txgbe_handle_devarg(__rte_unused const char *key, const char *value,
 		  void *extra_args)
 {
-	uint16_t *n = extra_args;
+	uint16_t *arg = extra_args;
+	char *endp;
+	unsigned long num;
 
 	if (value == NULL || extra_args == NULL)
 		return -EINVAL;
 
-	*n = (uint16_t)strtoul(value, NULL, 10);
-	if (*n == USHRT_MAX && errno == ERANGE)
-		return -1;
+	errno = 0;
+	num = strtoul(value, &endp, 10);
+	if (*value == '\0' || *endp != '\0')
+		return -EINVAL;
 
+	if (num > UINT16_MAX || errno == ERANGE)
+		return -ERANGE;
+	*arg = (uint16_t)num;
 	return 0;
 }
 
-- 
2.53.0


                 reply	other threads:[~2026-09-09 20:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260909204052.867168-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=jiawenwu@trustnetic.com \
    --cc=stable@dpdk.org \
    --cc=zaiyuwang@trustnetic.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox