diff options
author | David Disseldorp <ddiss@suse.de> | 2024-02-02 07:40:48 +0100 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2024-02-02 19:53:08 +0100 |
commit | 7c655bee5cd8e060983bd89460fffc1f9f780cda (patch) | |
tree | b0539ee782798e109f4f7ee8c4886433cf98584f /security/selinux | |
parent | selinux: correct return values in selinux_socket_getpeersec_dgram() (diff) | |
download | linux-7c655bee5cd8e060983bd89460fffc1f9f780cda.tar.xz linux-7c655bee5cd8e060983bd89460fffc1f9f780cda.zip |
selinux: only filter copy-up xattrs following initialization
Extended attribute copy-up functionality added via 19472b69d639d
("selinux: Implementation for inode_copy_up_xattr() hook") sees
"security.selinux" contexts dropped, instead relying on contexts
applied via the inode_copy_up() hook.
When copy-up takes place during early boot, prior to selinux
initialization / policy load, the context stripping can be unwanted
and unexpected.
With this change, filtering of "security.selinux" xattrs will only occur
after selinux initialization.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r-- | security/selinux/hooks.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 630ada3d208c..a0fde0641f77 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3533,9 +3533,10 @@ static int selinux_inode_copy_up_xattr(const char *name) { /* The copy_up hook above sets the initial context on an inode, but we * don't then want to overwrite it by blindly copying all the lower - * xattrs up. Instead, we have to filter out SELinux-related xattrs. + * xattrs up. Instead, filter out SELinux-related xattrs following + * policy load. */ - if (strcmp(name, XATTR_NAME_SELINUX) == 0) + if (selinux_initialized() && strcmp(name, XATTR_NAME_SELINUX) == 0) return 1; /* Discard */ /* * Any other attribute apart from SELINUX is not claimed, supported |