]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Use user_path_at for path resolution in uprobe_multi
authorJiri Olsa <jolsa@kernel.org>
Thu, 11 Jun 2026 11:42:25 +0000 (13:42 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 15 Jun 2026 00:24:25 +0000 (17:24 -0700)
Resolve the uprobe_multi user path with user_path_at() instead of copying
the string with strndup_user() and passing it to kern_path(). This removes
the temporary allocation and keeps the lookup logic in one helper.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20260611114230.950379-3-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c

index b5a12af2d3f8a68d1405570e3cf510a951fab91f..f8990bc6b64c3b95c12e2e76310593556c27c803 100644 (file)
@@ -3227,7 +3227,6 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
        unsigned long size;
        u32 flags, cnt, i;
        struct path path;
-       char *name;
        pid_t pid;
        int err;
 
@@ -3272,14 +3271,7 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
            !access_ok(ucookies, size))
                return -EFAULT;
 
-       name = strndup_user(upath, PATH_MAX);
-       if (IS_ERR(name)) {
-               err = PTR_ERR(name);
-               return err;
-       }
-
-       err = kern_path(name, LOOKUP_FOLLOW, &path);
-       kfree(name);
+       err = user_path_at(AT_FDCWD, upath, LOOKUP_FOLLOW, &path);
        if (err)
                return err;