[PATCH v2 30/51] net: pktgen: reject device names with a '/'

Christian Brauner brauner at kernel.org
Wed Nov 4 09:47:16 PST 2026


"add_device" takes a name like eth0 at 1. Only the part in front of the
'@' has to name a network device. The rest is free text and all of it
becomes the name of a file in /proc/net/pktgen, where procfs takes a
'/' as a directory separator. So "add_device lo at a/b" makes procfs look
for a directory "lo at a" that doesn't exist and warn about it. Any user
can do that in a network namespace of its own:

  name 'lo at a/b'
  WARNING: fs/proc/generic.c:174 at __xlate_proc_name+0xb1/0xf0, CPU#3: bash/241
  Call Trace:
   __proc_create+0xd0/0x9b0
   proc_create_reg+0x45/0xf0
   proc_create_data+0x77/0xf0
   pktgen_thread_write+0xd8d/0x1750

With panic_on_warn that takes the machine down. And if "lo at a" exists
because somebody added a device of that name, procfs used to register
the new entry below that regular file, and removing "lo at a" freed both.

Reject names with a '/'.

Reported-by: Chris Mason <mason at kernel.org>
Fixes: e6fce5b916cd ("pktgen: multiqueue etc.")
Cc: stable at vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
---
 net/core/pktgen.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index d63eeadddfcc..02af70d360bc 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3831,6 +3831,10 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
 	int err;
 	int node = cpu_to_node(t->cpu);
 
+	/* The name becomes the name of a file in /proc/net/pktgen. */
+	if (strchr(ifname, '/'))
+		return -EINVAL;
+
 	/* We don't allow a device to be on several threads */
 
 	if (__pktgen_NN_threads(t->net, ifname, FIND)) {

-- 
2.53.0




More information about the linux-um mailing list