linux-stable/security/selinux
Ondrej Mosnacek 87b7a2c910 selinux: fix handling of empty opts in selinux_fs_context_submount()
commit ccf1dab96b upstream.

selinux_set_mnt_opts() relies on the fact that the mount options pointer
is always NULL when all options are unset (specifically in its
!selinux_initialized() branch. However, the new
selinux_fs_context_submount() hook breaks this rule by allocating a new
structure even if no options are set. That causes any submount created
before a SELinux policy is loaded to be rejected in
selinux_set_mnt_opts().

Fix this by making selinux_fs_context_submount() leave fc->security
set to NULL when there are no options to be copied from the reference
superblock.

Cc: <stable@vger.kernel.org>
Reported-by: Adam Williamson <awilliam@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2236345
Fixes: d80a8f1b58 ("vfs, security: Fix automount superblock LSM init problem, preventing NFS sb sharing")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-23 11:14:36 +02:00
..
include selinux: make labeled NFS work when mounted before policy load 2023-05-30 17:44:34 -04:00
ss selinux: set next pointer before attaching to list 2023-08-18 16:13:03 -04:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kconfig selinux: remove the runtime disable functionality 2023-03-20 12:34:23 -04:00
Makefile selinux: fix Makefile for versions of make < v4.3 2023-06-02 15:34:29 -04:00
avc.c selinux: drop return at end of void function avc_insert() 2023-05-08 16:47:32 -04:00
hooks.c selinux: fix handling of empty opts in selinux_fs_context_submount() 2023-09-23 11:14:36 +02:00
ibpkey.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00
ima.c selinux: adjust typos in comments 2023-05-08 16:44:01 -04:00
netif.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00
netlabel.c selinux: Implement mptcp_add_subflow hook 2023-05-18 13:11:10 -04:00
netlink.c selinux: mark some global variables __ro_after_init 2021-01-12 10:08:55 -05:00
netnode.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00
netport.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00
nlmsgtab.c selinux: resolve checkpatch errors 2022-05-03 13:59:15 -04:00
selinuxfs.c selinux: declare read-only data arrays const 2023-05-08 16:52:05 -04:00
status.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00
xfrm.c selinux: stop passing selinux_state pointers and their offspring 2023-03-14 15:22:45 -04:00