Patch "ovl: skip getxattr of security labels" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ovl: skip getxattr of security labels

to the 5.10-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:
     ovl-skip-getxattr-of-security-labels.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bcf0873d1acd5e20ae8adfbc47375e6efdd4a218
Author: Amir Goldstein <amir73il@xxxxxxxxx>
Date:   Sat Dec 19 12:16:08 2020 +0200

    ovl: skip getxattr of security labels
    
    [ Upstream commit 03fedf93593c82538b18476d8c4f0e8f8435ea70 ]
    
    When inode has no listxattr op of its own (e.g. squashfs) vfs_listxattr
    calls the LSM inode_listsecurity hooks to list the xattrs that LSMs will
    intercept in inode_getxattr hooks.
    
    When selinux LSM is installed but not initialized, it will list the
    security.selinux xattr in inode_listsecurity, but will not intercept it
    in inode_getxattr.  This results in -ENODATA for a getxattr call for an
    xattr returned by listxattr.
    
    This situation was manifested as overlayfs failure to copy up lower
    files from squashfs when selinux is built-in but not initialized,
    because ovl_copy_xattr() iterates the lower inode xattrs by
    vfs_listxattr() and vfs_getxattr().
    
    ovl_copy_xattr() skips copy up of security labels that are indentified by
    inode_copy_up_xattr LSM hooks, but it does that after vfs_getxattr().
    Since we are not going to copy them, skip vfs_getxattr() of the security
    labels.
    
    Reported-by: Michael Labriola <michael.d.labriola@xxxxxxxxx>
    Tested-by: Michael Labriola <michael.d.labriola@xxxxxxxxx>
    Link: https://lore.kernel.org/linux-unionfs/2nv9d47zt7.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx/
    Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
    Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 955ecd4030f04..89d5d59c7d7a4 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -84,6 +84,14 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
 
 		if (ovl_is_private_xattr(sb, name))
 			continue;
+
+		error = security_inode_copy_up_xattr(name);
+		if (error < 0 && error != -EOPNOTSUPP)
+			break;
+		if (error == 1) {
+			error = 0;
+			continue; /* Discard */
+		}
 retry:
 		size = vfs_getxattr(old, name, value, value_size);
 		if (size == -ERANGE)
@@ -107,13 +115,6 @@ retry:
 			goto retry;
 		}
 
-		error = security_inode_copy_up_xattr(name);
-		if (error < 0 && error != -EOPNOTSUPP)
-			break;
-		if (error == 1) {
-			error = 0;
-			continue; /* Discard */
-		}
 		error = vfs_setxattr(new, name, value, size, 0);
 		if (error) {
 			if (error != -EOPNOTSUPP || ovl_must_copy_xattr(name))



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux