Skip to content

Commit

Permalink
mnt_idmapping: remove check_fsmapping()
Browse files Browse the repository at this point in the history
The helper is a bit pointless. Just open-code the check.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
brauner committed Nov 28, 2023
1 parent 71eb6b6 commit e65a29f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
17 changes: 2 additions & 15 deletions fs/mnt_idmapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ struct mnt_idmap nop_mnt_idmap = {
};
EXPORT_SYMBOL_GPL(nop_mnt_idmap);

/**
* check_fsmapping - check whether an mount idmapping is allowed
* @idmap: idmap of the relevent mount
* @sb: super block of the filesystem
*
* Return: true if @idmap is allowed, false if not.
*/
bool check_fsmapping(const struct mnt_idmap *idmap,
const struct super_block *sb)
{
return idmap->owner != sb->s_user_ns;
}

/**
* initial_idmapping - check whether this is the initial mapping
* @ns: idmapping to check
Expand Down Expand Up @@ -94,8 +81,8 @@ static inline bool no_idmapping(const struct user_namespace *mnt_userns,
*/

vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
struct user_namespace *fs_userns,
kuid_t kuid)
struct user_namespace *fs_userns,
kuid_t kuid)
{
uid_t uid;
struct user_namespace *mnt_userns = idmap->owner;
Expand Down
2 changes: 1 addition & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4289,7 +4289,7 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
* Creating an idmapped mount with the filesystem wide idmapping
* doesn't make sense so block that. We don't allow mushy semantics.
*/
if (!check_fsmapping(kattr->mnt_idmap, m->mnt_sb))
if (kattr->mnt_userns == m->mnt_sb->s_user_ns)
return -EINVAL;

/*
Expand Down
3 changes: 0 additions & 3 deletions include/linux/mnt_idmapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,4 @@ static inline kgid_t mapped_fsgid(struct mnt_idmap *idmap,
return from_vfsgid(idmap, fs_userns, VFSGIDT_INIT(current_fsgid()));
}

bool check_fsmapping(const struct mnt_idmap *idmap,
const struct super_block *sb);

#endif /* _LINUX_MNT_IDMAPPING_H */

0 comments on commit e65a29f

Please sign in to comment.