Skip to content

Commit e1ae035

Browse files
braunergregkh
authored andcommitted
ntfs: fix acl handling
[ Upstream commit 0c3bc78 ] While looking at our current POSIX ACL handling in the context of some overlayfs work I went through a range of other filesystems checking how they handle them currently and encountered ntfs3. The posic_acl_{from,to}_xattr() helpers always need to operate on the filesystem idmapping. Since ntfs3 can only be mounted in the initial user namespace the relevant idmapping is init_user_ns. The posix_acl_{from,to}_xattr() helpers are concerned with translating between the kernel internal struct posix_acl{_entry} and the uapi struct posix_acl_xattr_{header,entry} and the kernel internal data structure is cached filesystem wide. Additional idmappings such as the caller's idmapping or the mount's idmapping are handled higher up in the VFS. Individual filesystems usually do not need to concern themselves with these. The posix_acl_valid() helper is concerned with checking whether the values in the kernel internal struct posix_acl can be represented in the filesystem's idmapping. IOW, if they can be written to disk. So this helper too needs to take the filesystem's idmapping. Fixes: be71b5c ("fs/ntfs3: Add attrib operations") Cc: Konstantin Komarov <[email protected]> Cc: [email protected] Signed-off-by: Christian Brauner (Microsoft) <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d28f319 commit e1ae035

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

fs/ntfs3/xattr.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
476476
}
477477

478478
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
479-
static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
480-
struct inode *inode, int type,
479+
static struct posix_acl *ntfs_get_acl_ex(struct inode *inode, int type,
481480
int locked)
482481
{
483482
struct ntfs_inode *ni = ntfs_i(inode);
@@ -512,7 +511,7 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
512511

513512
/* Translate extended attribute to acl. */
514513
if (err >= 0) {
515-
acl = posix_acl_from_xattr(mnt_userns, buf, err);
514+
acl = posix_acl_from_xattr(&init_user_ns, buf, err);
516515
} else if (err == -ENODATA) {
517516
acl = NULL;
518517
} else {
@@ -535,8 +534,7 @@ struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu)
535534
if (rcu)
536535
return ERR_PTR(-ECHILD);
537536

538-
/* TODO: init_user_ns? */
539-
return ntfs_get_acl_ex(&init_user_ns, inode, type, 0);
537+
return ntfs_get_acl_ex(inode, type, 0);
540538
}
541539

542540
static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
@@ -588,7 +586,7 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
588586
value = kmalloc(size, GFP_NOFS);
589587
if (!value)
590588
return -ENOMEM;
591-
err = posix_acl_to_xattr(mnt_userns, acl, value, size);
589+
err = posix_acl_to_xattr(&init_user_ns, acl, value, size);
592590
if (err < 0)
593591
goto out;
594592
flags = 0;
@@ -639,7 +637,7 @@ static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
639637
if (!acl)
640638
return -ENODATA;
641639

642-
err = posix_acl_to_xattr(mnt_userns, acl, buffer, size);
640+
err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
643641
posix_acl_release(acl);
644642

645643
return err;
@@ -663,12 +661,12 @@ static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
663661
if (!value) {
664662
acl = NULL;
665663
} else {
666-
acl = posix_acl_from_xattr(mnt_userns, value, size);
664+
acl = posix_acl_from_xattr(&init_user_ns, value, size);
667665
if (IS_ERR(acl))
668666
return PTR_ERR(acl);
669667

670668
if (acl) {
671-
err = posix_acl_valid(mnt_userns, acl);
669+
err = posix_acl_valid(&init_user_ns, acl);
672670
if (err)
673671
goto release_and_out;
674672
}

0 commit comments

Comments
 (0)