path: root/fs/posix_acl.c
diff options
authorChristian Brauner <>2021-12-03 12:17:07 +0100
committerChristian Brauner <>2021-12-05 10:28:57 +0100
commitbd303368b776eead1c29e6cdda82bde7128b82a7 (patch)
tree30c56d570cfa5cb3d215504293957389731df621 /fs/posix_acl.c
parenta1ec9040a2a9122605ac26e5725c6de019184419 (diff)
fs: support mapped mounts of mapped filesystems
In previous patches we added new and modified existing helpers to handle idmapped mounts of filesystems mounted with an idmapping. In this final patch we convert all relevant places in the vfs to actually pass the filesystem's idmapping into these helpers. With this the vfs is in shape to handle idmapped mounts of filesystems mounted with an idmapping. Note that this is just the generic infrastructure. Actually adding support for idmapped mounts to a filesystem mountable with an idmapping is follow-up work. In this patch we extend the definition of an idmapped mount from a mount that that has the initial idmapping attached to it to a mount that has an idmapping attached to it which is not the same as the idmapping the filesystem was mounted with. As before we do not allow the initial idmapping to be attached to a mount. In addition this patch prevents that the idmapping the filesystem was mounted with can be attached to a mount created based on this filesystem. This has multiple reasons and advantages. First, attaching the initial idmapping or the filesystem's idmapping doesn't make much sense as in both cases the values of the i_{g,u}id and other places where k{g,u}ids are used do not change. Second, a user that really wants to do this for whatever reason can just create a separate dedicated identical idmapping to attach to the mount. Third, we can continue to use the initial idmapping as an indicator that a mount is not idmapped allowing us to continue to keep passing the initial idmapping into the mapping helpers to tell them that something isn't an idmapped mount even if the filesystem is mounted with an idmapping. Link: (v1) Link: (v2) Link: Cc: Seth Forshee <> Cc: Amir Goldstein <> Cc: Christoph Hellwig <> Cc: Al Viro <> CC: Reviewed-by: Seth Forshee <> Signed-off-by: Christian Brauner <>
Diffstat (limited to 'fs/posix_acl.c')
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 4b5fb9a9b90f..80acb6885cf9 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -376,8 +376,8 @@ posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
case ACL_USER:
uid = mapped_kuid_fs(mnt_userns,
- &init_user_ns,
- pa->e_uid);
+ i_user_ns(inode),
+ pa->e_uid);
if (uid_eq(uid, current_fsuid()))
goto mask;
@@ -391,8 +391,8 @@ posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
gid = mapped_kgid_fs(mnt_userns,
- &init_user_ns,
- pa->e_gid);
+ i_user_ns(inode),
+ pa->e_gid);
if (in_group_p(gid)) {
found = 1;
if ((pa->e_perm & want) == want)