From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] uninline may_mount() and don't opencode it in fspick(2)/fsopen(2)
Date: Fri, 20 May 2022 03:20:06 +0000 [thread overview]
Message-ID: <YocI5jIou18bDDuy@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <YocIiPQjR7tuYdkP@zeniv-ca.linux.org.uk>
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 | 4 ++--
fs/internal.h | 1 +
fs/namespace.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/fsopen.c b/fs/fsopen.c
index 27a890aa493a..fc9d2d9fd234 100644
--- a/fs/fsopen.c
+++ b/fs/fsopen.c
@@ -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 |
diff --git a/fs/internal.h b/fs/internal.h
index 8590c973c2f4..315ec2f419f7 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -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);
diff --git a/fs/namespace.c b/fs/namespace.c
index 40b994a29e90..6f91ce77e16b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1717,7 +1717,7 @@ void __detach_mounts(struct dentry *dentry)
/*
* 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);
}
--
2.30.2
next prev parent reply other threads:[~2022-05-20 3:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 3:17 [PATCHES] stuff from the last cycle that missed the window Al Viro
2022-05-20 3:17 ` [PATCH] fs/namei.c:reserve_stack(): tidy up the call of try_to_unlazy() Al Viro
2022-05-20 11:48 ` Christian Brauner
2022-05-20 3:18 ` [PATCH] get rid of dead code in legitimize_root() Al Viro
2022-05-20 3:20 ` Al Viro [this message]
2022-05-20 3:20 ` [PATCH] linux/mount.h: trim includes Al Viro
2022-05-20 3:22 ` [PATCH] m->mnt_root->d_inode->i_sb is a weird way to spell m->mnt_sb Al Viro
2022-05-20 3:23 ` [PATCH] blob_to_mnt(): kern_unmount() is needed to undo kern_mount() Al Viro
2022-05-20 3:23 ` [PATCH] move mount-related externs from fs.h to mount.h Al Viro
2022-05-20 11:54 ` Christian Brauner
2022-05-20 19:02 ` [PATCH] blob_to_mnt(): kern_unmount() is needed to undo kern_mount() Eric W. Biederman
2022-05-20 11:45 ` [PATCH] linux/mount.h: trim includes Christian Brauner
2022-05-20 11:44 ` [PATCH] uninline may_mount() and don't opencode it in fspick(2)/fsopen(2) Christian Brauner
2022-05-20 11:43 ` [PATCH] get rid of dead code in legitimize_root() Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YocI5jIou18bDDuy@zeniv-ca.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox