提交 4a8b34af 编写于 作者: C Christian Brauner 提交者: David Sterba

btrfs: handle ACLs on idmapped mounts

Make the ACL code idmapped mount aware. The POSIX default and POSIX
access ACLs are the only ACLs other than some specific xattrs that take
DAC permissions into account. On an idmapped mount they need to be
translated according to the mount's userns. The main change is done to
__btrfs_set_acl() which is responsible for translating POSIX ACLs to
their final on-disk representation.

The btrfs_init_acl() helper does not need to take the idmapped mount
into account since it is called in the context of file creation
operations (mknod, create, mkdir, symlink, tmpfile) and is used for
btrfs_init_inode_security() to copy POSIX default and POSIX access
permissions from the parent directory. These ACLs need to be inherited
unmodified from the parent directory. This is identical to what we do
for ext4 and xfs.
Reviewed-by: NJosef Bacik <josef@toxicpanda.com>
Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 6623d9a0
...@@ -53,6 +53,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type) ...@@ -53,6 +53,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
} }
static int __btrfs_set_acl(struct btrfs_trans_handle *trans, static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
struct user_namespace *mnt_userns,
struct inode *inode, struct posix_acl *acl, int type) struct inode *inode, struct posix_acl *acl, int type)
{ {
int ret, size = 0; int ret, size = 0;
...@@ -114,12 +115,12 @@ int btrfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode, ...@@ -114,12 +115,12 @@ int btrfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
umode_t old_mode = inode->i_mode; umode_t old_mode = inode->i_mode;
if (type == ACL_TYPE_ACCESS && acl) { if (type == ACL_TYPE_ACCESS && acl) {
ret = posix_acl_update_mode(&init_user_ns, inode, ret = posix_acl_update_mode(mnt_userns, inode,
&inode->i_mode, &acl); &inode->i_mode, &acl);
if (ret) if (ret)
return ret; return ret;
} }
ret = __btrfs_set_acl(NULL, inode, acl, type); ret = __btrfs_set_acl(NULL, mnt_userns, inode, acl, type);
if (ret) if (ret)
inode->i_mode = old_mode; inode->i_mode = old_mode;
return ret; return ret;
...@@ -140,14 +141,14 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans, ...@@ -140,14 +141,14 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
return ret; return ret;
if (default_acl) { if (default_acl) {
ret = __btrfs_set_acl(trans, inode, default_acl, ret = __btrfs_set_acl(trans, &init_user_ns, inode, default_acl,
ACL_TYPE_DEFAULT); ACL_TYPE_DEFAULT);
posix_acl_release(default_acl); posix_acl_release(default_acl);
} }
if (acl) { if (acl) {
if (!ret) if (!ret)
ret = __btrfs_set_acl(trans, inode, acl, ret = __btrfs_set_acl(trans, &init_user_ns, inode, acl,
ACL_TYPE_ACCESS); ACL_TYPE_ACCESS);
posix_acl_release(acl); posix_acl_release(acl);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册