Skip to contentSkip to conversation

net/ark: fix unsafe env variable in extension loading

PATCH Superseded Denis Sergeev 2 participants 4 messages Jun 3 – Jun 8 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ark: fix unsafe env variable in extension loading

The ARK_EXT_PATH environment variable is passed to dlopen without verifying process privileges. In a setuid/setgid scenario, this could allow loading an arbitrary shared library with elevated privileges.

Add a check that effective user/group IDs match real IDs before trusting the environment variable, consistent with the same protection already present in the mlx5 driver.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 727b3fe292 ("net/ark: integrate PMD")
---
 drivers/net/ark/ark_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +11 -1
index 8b25ed948f..e25478103b 100644
@@ -211,9 +211,19 @@ static int
 check_for_ext(struct ark_adapter *ark)
 {
 	int found = 0;
+	const char *dllpath;
+
+	/*
+	 * A basic security check is necessary before trusting
+	 * ARK_EXT_PATH environment variable.
+	 */
+	if (geteuid() != getuid() || getegid() != getgid()) {
+		ARK_PMD_LOG(DEBUG, "EXT ignoring ARK_EXT_PATH under setuid/setgid\n");
+		return 0;
+	}
 
 	/* Get the env */
-	const char *dllpath = getenv("ARK_EXT_PATH");
+	dllpath = getenv("ARK_EXT_PATH");
 
 	if (dllpath == NULL) {
 		ARK_PMD_LOG(DEBUG, "EXT NO dll path specified\n");
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/1 net/ark: fix unsafe env variable in extension loading

The ARK_EXT_PATH environment variable is passed to dlopen without verifying process privileges. In a setuid/setgid scenario, this could allow loading an arbitrary shared library with elevated privileges.

Add a check that effective user/group IDs match real IDs before trusting the environment variable, consistent with the same protection already present in the mlx5 driver.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 727b3fe292bc ("net/ark: integrate PMD")

---
v2:
* Fix Fixes: tag to use 12-char sha1 (checkpatch BAD_FIXES_TAG)

 drivers/net/ark/ark_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ark/ark_ethdev.c +11 -1
index 8b25ed948f..e25478103b 100644
@@ -211,9 +211,19 @@ static int
 check_for_ext(struct ark_adapter *ark)
 {
 	int found = 0;
+	const char *dllpath;
+
+	/*
+	 * A basic security check is necessary before trusting
+	 * ARK_EXT_PATH environment variable.
+	 */
+	if (geteuid() != getuid() || getegid() != getgid()) {
+		ARK_PMD_LOG(DEBUG, "EXT ignoring ARK_EXT_PATH under setuid/setgid\n");
+		return 0;
+	}
 
 	/* Get the env */
-	const char *dllpath = getenv("ARK_EXT_PATH");
+	dllpath = getenv("ARK_EXT_PATH");
 
 	if (dllpath == NULL) {
 		ARK_PMD_LOG(DEBUG, "EXT NO dll path specified\n");
Signature · 1 line
2.50.1
#2 lore raw
Quoted 9 lines · On Wed, 3 Jun 2026 08:32:45 +0300 Denis Sergeev <[email protected]> wrote:

The ARK_EXT_PATH environment variable is passed to dlopen without verifying process privileges. In a setuid/setgid scenario, this could allow loading an arbitrary shared library with elevated privileges.

Add a check that effective user/group IDs match real IDs before trusting the environment variable, consistent with the same protection already present in the mlx5 driver.

Quoted 6 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 727b3fe292bc ("net/ark: integrate PMD")

Thanks for the report, but it makes no sense.
DPDK already load shared libraries via -d command line arg without checking. And running DPDK application as setuid would be completely unsafe. The startup is not hardened in anyway.

NAK

That said, it would be good if DPDK had some security documentation about what the trust boundary is and what capabilities are needed.

#3 lore raw
In reply to Denis Sergeev
Quoted 9 lines · On Wed, 3 Jun 2026 08:26:00 +0300 Denis Sergeev <[email protected]> wrote:
drivers/net/ark/ark_ethdev.c +1 -0
index 8b25ed948f..e25478103b 100644
@@ -211,9 +211,19 @@ static int
 check_for_ext(struct ark_adapter *ark)
 {
 	int found = 0;
+	const char *dllpath;

drivers/net/ark/ark_ethdev.c static int · line 224

Quoted 10 lines
drivers/net/ark/ark_ethdev.c +9 -0
+
+	/*
+	 * A basic security check is necessary before trusting
+	 * ARK_EXT_PATH environment variable.
+	 */
+	if (geteuid() != getuid() || getegid() != getgid()) {
+		ARK_PMD_LOG(DEBUG, "EXT ignoring ARK_EXT_PATH under setuid/setgid\n");
+		return 0;
+	}
 

DPDK may be run in containers. This would break that.

The whole dlopen extension stuff in this driver is rubbish and should not have been allowed in. It creates testing and security nightmares.