aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2023-01-13 12:49:32 +0100
committerChristian Brauner (Microsoft) <brauner@kernel.org>2023-01-19 09:24:30 +0100
commit4d7ca4090184c153f8ccb1a68ca5cf136dac108b (patch)
tree2beb8f9a791c2aeafd4dad7e052aa260b6926ab7 /include/linux/fs.h
parentc14329d39f2daa8132e1bbe5cc531da387bcf44a (diff)
downloadlinux-4d7ca4090184c153f8ccb1a68ca5cf136dac108b.tar.gz
fs: port vfs{g,u}id helpers to mnt_idmap
Convert to struct mnt_idmap. Last cycle we merged the necessary infrastructure in 256c8aed2b42 ("fs: introduce dedicated idmap type for mounts"). This is just the conversion to struct mnt_idmap. Currently we still pass around the plain namespace that was attached to a mount. This is in general pretty convenient but it makes it easy to conflate namespaces that are relevant on the filesystem with namespaces that are relevent on the mount level. Especially for non-vfs developers without detailed knowledge in this area this can be a potential source for bugs. Once the conversion to struct mnt_idmap is done all helpers down to the really low-level helpers will take a struct mnt_idmap argument instead of two namespace arguments. This way it becomes impossible to conflate the two eliminating the possibility of any bugs. All of the vfs and all filesystems only operate on struct mnt_idmap. Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 54a95ed68322c0..bd040fe31014f7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1642,8 +1642,7 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
static inline vfsuid_t i_uid_into_vfsuid(struct mnt_idmap *idmap,
const struct inode *inode)
{
- struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
- return make_vfsuid(mnt_userns, i_user_ns(inode), inode->i_uid);
+ return make_vfsuid(idmap, i_user_ns(inode), inode->i_uid);
}
/**
@@ -1679,10 +1678,8 @@ static inline void i_uid_update(struct mnt_idmap *idmap,
const struct iattr *attr,
struct inode *inode)
{
- struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
-
if (attr->ia_valid & ATTR_UID)
- inode->i_uid = from_vfsuid(mnt_userns, i_user_ns(inode),
+ inode->i_uid = from_vfsuid(idmap, i_user_ns(inode),
attr->ia_vfsuid);
}
@@ -1697,8 +1694,7 @@ static inline void i_uid_update(struct mnt_idmap *idmap,
static inline vfsgid_t i_gid_into_vfsgid(struct mnt_idmap *idmap,
const struct inode *inode)
{
- struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
- return make_vfsgid(mnt_userns, i_user_ns(inode), inode->i_gid);
+ return make_vfsgid(idmap, i_user_ns(inode), inode->i_gid);
}
/**
@@ -1734,10 +1730,8 @@ static inline void i_gid_update(struct mnt_idmap *idmap,
const struct iattr *attr,
struct inode *inode)
{
- struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
-
if (attr->ia_valid & ATTR_GID)
- inode->i_gid = from_vfsgid(mnt_userns, i_user_ns(inode),
+ inode->i_gid = from_vfsgid(idmap, i_user_ns(inode),
attr->ia_vfsgid);
}