Skip to content

Commit a5f85d7

Browse files
author
Al Viro
committed
uninline may_mount() and don't opencode it in fspick(2)/fsopen(2)
It's done once per (mount-related) syscall and there's no point whatsoever making it inline. Signed-off-by: Al Viro <[email protected]>
1 parent 3123109 commit a5f85d7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

fs/fsopen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ SYSCALL_DEFINE2(fsopen, const char __user *, _fs_name, unsigned int, flags)
119119
const char *fs_name;
120120
int ret;
121121

122-
if (!ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN))
122+
if (!may_mount())
123123
return -EPERM;
124124

125125
if (flags & ~FSOPEN_CLOEXEC)
@@ -162,7 +162,7 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags
162162
unsigned int lookup_flags;
163163
int ret;
164164

165-
if (!ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN))
165+
if (!may_mount())
166166
return -EPERM;
167167

168168
if ((flags & ~(FSPICK_CLOEXEC |

fs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern int __mnt_want_write_file(struct file *);
8484
extern void __mnt_drop_write_file(struct file *);
8585

8686
extern void dissolve_on_fput(struct vfsmount *);
87+
extern bool may_mount(void);
8788

8889
int path_mount(const char *dev_name, struct path *path,
8990
const char *type_page, unsigned long flags, void *data_page);

fs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ void __detach_mounts(struct dentry *dentry)
17601760
/*
17611761
* Is the caller allowed to modify his namespace?
17621762
*/
1763-
static inline bool may_mount(void)
1763+
bool may_mount(void)
17641764
{
17651765
return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
17661766
}

0 commit comments

Comments
 (0)