"add_device" takes a name like eth0@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@a/b" makes procfs look for a directory "lo@a" that doesn't exist and warn about it. Any user can do that in a network namespace of its own:
name 'lo@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@a" exists because somebody added a device of that name, procfs used to register the new entry below that regular file, and removing "lo@a" freed both. Reject names with a '/'. Reported-by: Chris Mason <[email protected]> Fixes: e6fce5b916cd ("pktgen: multiqueue etc.") Cc: [email protected] Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- 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
