From: Denis Sergeev <denserg.edu@gmail.com>
To: dev@dpdk.org
Cc: shepard.siegel@atomicrules.com, ed.czeck@atomicrules.com,
john.miller@atomicrules.com, sdl.dpdk@linuxtesting.org,
Denis Sergeev <denserg.edu@gmail.com>
Subject: [PATCH] net/ark: validate IPv4 octets in address parser
Date: Wed, 3 Jun 2026 08:47:38 +0300 [thread overview]
Message-ID: <20260603054742.120101-1-denserg.edu@gmail.com> (raw)
The IPv4 parsing helper used by pktgen and pktchkr reads each octet
with "%u". This allows values above 255 to be accepted from the
configuration file and encoded into unintended device register values.
Reject parsed octets outside the IPv4 byte range before assembling
the 32-bit address.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 9c7188a68d7b ("net/ark: provide API for hardware modules pktchkr and pktgen")
Signed-off-by: Denis Sergeev <denserg.edu@gmail.com>
---
drivers/net/ark/ark_pktchkr.c | 2 ++
drivers/net/ark/ark_pktgen.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
index e1f336c73c..76e6f42659 100644
--- a/drivers/net/ark/ark_pktchkr.c
+++ b/drivers/net/ark/ark_pktchkr.c
@@ -379,6 +379,8 @@ parse_ipv4_string(char const *ip_address)
if (sscanf(ip_address, "%u.%u.%u.%u",
&ip[0], &ip[1], &ip[2], &ip[3]) != 4)
return 0;
+ if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255)
+ return 0;
return ip[3] + ip[2] * 0x100 + ip[1] * 0x10000ul + ip[0] * 0x1000000ul;
}
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 69ff7072b2..0b7246c374 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -360,6 +360,8 @@ parse_ipv4_string(char const *ip_address)
if (sscanf(ip_address, "%u.%u.%u.%u",
&ip[0], &ip[1], &ip[2], &ip[3]) != 4)
return 0;
+ if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255)
+ return 0;
return ip[3] + ip[2] * 0x100 + ip[1] * 0x10000ul + ip[0] * 0x1000000ul;
}
--
2.50.1
next reply other threads:[~2026-06-03 5:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 5:47 Denis Sergeev [this message]
2026-06-03 17:29 ` [PATCH] net/ark: validate IPv4 octets in address parser Stephen Hemminger
2026-06-04 3:48 ` [PATCH v2] net/ark: use standard IPv4 " Denis Sergeev
2026-06-04 16:55 ` Stephen Hemminger
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=20260603054742.120101-1-denserg.edu@gmail.com \
--to=denserg.edu@gmail.com \
--cc=dev@dpdk.org \
--cc=ed.czeck@atomicrules.com \
--cc=john.miller@atomicrules.com \
--cc=sdl.dpdk@linuxtesting.org \
--cc=shepard.siegel@atomicrules.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