Skip to content

Commit e65a29f

Browse files
committed
mnt_idmapping: remove check_fsmapping()
The helper is a bit pointless. Just open-code the check. Link: https://lore.kernel.org/r/20231122-vfs-mnt_idmap-v1-1-dae4abdde5bd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 71eb6b6 commit e65a29f

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

fs/mnt_idmapping.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ struct mnt_idmap nop_mnt_idmap = {
2525
};
2626
EXPORT_SYMBOL_GPL(nop_mnt_idmap);
2727

28-
/**
29-
* check_fsmapping - check whether an mount idmapping is allowed
30-
* @idmap: idmap of the relevent mount
31-
* @sb: super block of the filesystem
32-
*
33-
* Return: true if @idmap is allowed, false if not.
34-
*/
35-
bool check_fsmapping(const struct mnt_idmap *idmap,
36-
const struct super_block *sb)
37-
{
38-
return idmap->owner != sb->s_user_ns;
39-
}
40-
4128
/**
4229
* initial_idmapping - check whether this is the initial mapping
4330
* @ns: idmapping to check
@@ -94,8 +81,8 @@ static inline bool no_idmapping(const struct user_namespace *mnt_userns,
9481
*/
9582

9683
vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
97-
struct user_namespace *fs_userns,
98-
kuid_t kuid)
84+
struct user_namespace *fs_userns,
85+
kuid_t kuid)
9986
{
10087
uid_t uid;
10188
struct user_namespace *mnt_userns = idmap->owner;

fs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4289,7 +4289,7 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
42894289
* Creating an idmapped mount with the filesystem wide idmapping
42904290
* doesn't make sense so block that. We don't allow mushy semantics.
42914291
*/
4292-
if (!check_fsmapping(kattr->mnt_idmap, m->mnt_sb))
4292+
if (kattr->mnt_userns == m->mnt_sb->s_user_ns)
42934293
return -EINVAL;
42944294

42954295
/*

include/linux/mnt_idmapping.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,4 @@ static inline kgid_t mapped_fsgid(struct mnt_idmap *idmap,
244244
return from_vfsgid(idmap, fs_userns, VFSGIDT_INIT(current_fsgid()));
245245
}
246246

247-
bool check_fsmapping(const struct mnt_idmap *idmap,
248-
const struct super_block *sb);
249-
250247
#endif /* _LINUX_MNT_IDMAPPING_H */

0 commit comments

Comments
 (0)