]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mnt_idmapping: remove check_fsmapping()
authorChristian Brauner <brauner@kernel.org>
Wed, 22 Nov 2023 12:44:37 +0000 (13:44 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 28 Nov 2023 13:08:47 +0000 (14:08 +0100)
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>
fs/mnt_idmapping.c
fs/namespace.c
include/linux/mnt_idmapping.h

index 57d1dedf3f8fa72fe7cb32316ee72961559a82c6..2674942311c3c54af41ef02719323d3b5c349b75 100644 (file)
@@ -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
@@ -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;
index b899cbbe24d9959c94ba38fca9eb6a4abc28d813..78366f114515f5841b1a5ddbc679e68f75692c21 100644 (file)
@@ -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;
 
        /*
index b8da2db4ecd295672ec512800ffc3b50b363c63d..cd4d5c8781f54e0531bf713fd2d2957c97e41f63 100644 (file)
@@ -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 */