uninline may_mount() and don't opencode it in fspick(2)/fsopen(2)
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 1 Mar 2022 05:05:29 +0000 (00:05 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 20 May 2022 03:25:10 +0000 (23:25 -0400)
It's done once per (mount-related) syscall and there's no point
whatsoever making it inline.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/fsopen.c
fs/internal.h
fs/namespace.c

index 27a890a..fc9d2d9 100644 (file)
@@ -119,7 +119,7 @@ SYSCALL_DEFINE2(fsopen, const char __user *, _fs_name, unsigned int, flags)
        const char *fs_name;
        int ret;
 
-       if (!ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN))
+       if (!may_mount())
                return -EPERM;
 
        if (flags & ~FSOPEN_CLOEXEC)
@@ -162,7 +162,7 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags
        unsigned int lookup_flags;
        int ret;
 
-       if (!ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN))
+       if (!may_mount())
                return -EPERM;
 
        if ((flags & ~(FSPICK_CLOEXEC |
index 08503dc..09ed7fe 100644 (file)
@@ -84,6 +84,7 @@ extern int __mnt_want_write_file(struct file *);
 extern void __mnt_drop_write_file(struct file *);
 
 extern void dissolve_on_fput(struct vfsmount *);
+extern bool may_mount(void);
 
 int path_mount(const char *dev_name, struct path *path,
                const char *type_page, unsigned long flags, void *data_page);
index a0a36bf..c3a80ff 100644 (file)
@@ -1760,7 +1760,7 @@ out_unlock:
 /*
  * Is the caller allowed to modify his namespace?
  */
-static inline bool may_mount(void)
+bool may_mount(void)
 {
        return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
 }