]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
statmount: permission check should return EPERM
authorBhavik Sachdev <b.sachdev1904@gmail.com>
Sat, 29 Nov 2025 09:11:20 +0000 (14:41 +0530)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Dec 2025 13:13:13 +0000 (14:13 +0100)
Currently, statmount() returns ENOENT when caller is not CAP_SYS_ADMIN
in the user namespace owner of target mount namespace. This should be
EPERM instead.

Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Bhavik Sachdev <b.sachdev1904@gmail.com>
Link: https://patch.msgid.link/20251129091455.757724-2-b.sachdev1904@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c

index c58674a20cad54a9d015cbea1928d7725c8b07cf..f6879f282daec2a86aff84244b81c13b8a9f6a21 100644 (file)
@@ -5780,7 +5780,7 @@ SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req,
 
        if (kreq.mnt_ns_id && (ns != current->nsproxy->mnt_ns) &&
            !ns_capable_noaudit(ns->user_ns, CAP_SYS_ADMIN))
-               return -ENOENT;
+               return -EPERM;
 
        ks = kmalloc(sizeof(*ks), GFP_KERNEL_ACCOUNT);
        if (!ks)