Patch "fs: fix acl translation" has been added to the 5.17-stable tree
Subsystems (2)
[email protected]
AppliedThis is a note to let you know that I've just added the patch titled
fs: fix acl translation
to the 5.17-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
fs-fix-acl-translation.patch
and it can be found in the queue-5.17 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From 705191b03d507744c7e097f78d583621c14988ac Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Tue, 19 Apr 2022 15:14:23 +0200
Subject: fs: fix acl translation
From: Christian Brauner <[email protected]>
commit 705191b03d507744c7e097f78d583621c14988ac upstream.
Last cycle we extended the idmapped mounts infrastructure to support idmapped mounts of idmapped filesystems (No such filesystem yet exist.). Since then, the meaning of an idmapped mount is a mount whose idmapping is different from the filesystems idmapping.
While doing that work we missed to adapt the acl translation helpers. They still assume that checking for the identity mapping is enough. But they need to use the no_idmapping() helper instead.
Note, POSIX ACLs are always translated right at the userspace-kernel boundary using the caller's current idmapping and the initial idmapping. The order depends on whether we're coming from or going to userspace. The filesystem's idmapping doesn't matter at the border.
Consequently, if a non-idmapped mount is passed we need to make sure to always pass the initial idmapping as the mount's idmapping and not the filesystem idmapping. Since it's irrelevant here it would yield invalid ids and prevent setting acls for filesystems that are mountable in a userns and support posix acls (tmpfs and fuse).
I verified the regression reported in [1] and verified that this patch fixes it. A regression test will be added to xfstests in parallel.
--- fs/posix_acl.c | 10 ++++++++++ fs/xattr.c | 6 ++++-- include/linux/posix_acl_xattr.h | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-)
fs/posix_acl.c +10 -0
@@ -759,9 +759,14 @@ static void posix_acl_fix_xattr_userns( }void posix_acl_fix_xattr_from_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size) {struct user_namespace *user_ns =current_user_ns (); + +/* Leave ids untouched on non-idmapped mounts. */ +if (no_idmapping (mnt_userns,i_user_ns (inode))) + mnt_userns = &init_user_ns;if ((user_ns == &init_user_ns) && (mnt_userns == &init_user_ns))return ; posix_acl_fix_xattr_userns(&init_user_ns, user_ns, mnt_userns, value,
@@ -769,9 +774,14 @@ void posix_acl_fix_xattr_from_user(struc }void posix_acl_fix_xattr_to_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size) {struct user_namespace *user_ns =current_user_ns (); + +/* Leave ids untouched on non-idmapped mounts. */ +if (no_idmapping (mnt_userns,i_user_ns (inode))) + mnt_userns = &init_user_ns;if ((user_ns == &init_user_ns) && (mnt_userns == &init_user_ns))return ; posix_acl_fix_xattr_userns(user_ns, &init_user_ns, mnt_userns, value,
fs/xattr.c +4 -2
@@ -569,7 +569,8 @@ setxattr(struct user_namespace *mnt_user }if ((strcmp (kname,XATTR_NAME_POSIX_ACL_ACCESS ) ==0 ) || (strcmp (kname,XATTR_NAME_POSIX_ACL_DEFAULT ) ==0 )) -posix_acl_fix_xattr_from_user (mnt_userns, kvalue, size); +posix_acl_fix_xattr_from_user (mnt_userns,d_inode (d), + kvalue, size); } error =vfs_setxattr (mnt_userns, d, kname, kvalue, size, flags);
@@ -667,7 +668,8 @@ getxattr(struct user_namespace *mnt_userif (error >0 ) {if ((strcmp (kname,XATTR_NAME_POSIX_ACL_ACCESS ) ==0 ) || (strcmp (kname,XATTR_NAME_POSIX_ACL_DEFAULT ) ==0 )) -posix_acl_fix_xattr_to_user (mnt_userns, kvalue, error); +posix_acl_fix_xattr_to_user (mnt_userns,d_inode (d), + kvalue, error);if (size &©_to_user (value, kvalue, error)) error = -EFAULT ; }else if (error == -ERANGE && size >=XATTR_SIZE_MAX ) {
include/linux/posix_acl_xattr.h +4 -0
@@ -34,15 +34,19 @@ posix_acl_xattr_count(size_t size)#ifdef CONFIG_FS_POSIX_ACL void posix_acl_fix_xattr_from_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size);void posix_acl_fix_xattr_to_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size);#else static inline void posix_acl_fix_xattr_from_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size) { }static inline void posix_acl_fix_xattr_to_user (struct user_namespace *mnt_userns, +struct inode *inode,void *value,size_t size) { }
Patches currently in stable-queue which might be from [email protected] are
queue-5.17/fs-fix-acl-translation.patch