kernel_optimize_test/security
Amir Goldstein 2fe9215301 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: c8e222616c ("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>
2021-03-04 11:38:28 +01:00
..
apparmor
bpf
integrity certs: Fix blacklist flag type confusion 2021-03-04 11:37:59 +01:00
keys certs: Fix blacklist flag type confusion 2021-03-04 11:37:59 +01:00
loadpin
lockdown
safesetid
selinux selinux: fix inconsistency between inode_getxattr and inode_listsecurity 2021-03-04 11:38:28 +01:00
smack Smack: Handle io_uring kernel thread privileges 2020-12-30 11:54:02 +01:00
tomoyo
yama
commoncap.c capabilities: Don't allow writing ambiguous v3 file capabilities 2021-03-04 11:37:52 +01:00
device_cgroup.c
inode.c
Kconfig
Kconfig.hardening
lsm_audit.c dump_common_audit_data(): fix racy accesses to ->d_name 2021-01-19 18:27:29 +01:00
Makefile
min_addr.c
security.c