]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
selinux: fix inconsistency between inode_getxattr and inode_listsecurity
authorAmir Goldstein <amir73il@gmail.com>
Sat, 19 Dec 2020 10:05:27 +0000 (12:05 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 15 Mar 2021 14:09:41 +0000 (15:09 +0100)
commit47a4cc642bc8f7d53676ad1964ec8b6e5cb9a43c
treeda116d95ecfd3925cd6128400e7f28885ddf9f1a
parent7e54ca60813a114c0a45fc9c074a35f2fe9bfab6
selinux: fix inconsistency between inode_getxattr and inode_listsecurity

commit a9ffe682c58aaff643764547f5420e978b6e0830 upstream.

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().

Match the logic of inode_listsecurity to that of inode_getxattr and
do not list the security.selinux xattr if selinux is not initialized.

Reported-by: Michael Labriola <michael.d.labriola@gmail.com>
Tested-by: Michael Labriola <michael.d.labriola@gmail.com>
Link: https://lore.kernel.org/linux-unionfs/2nv9d47zt7.fsf@aldarion.sourceruckus.org/
Fixes: c8e222616c7e ("selinux: allow reading labels before policy is loaded")
Cc: stable@vger.kernel.org#v5.9+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
security/selinux/hooks.c