Skip to content

Commit 7c655be

Browse files
ddisspcmoore
authored andcommitted
selinux: only filter copy-up xattrs following initialization
Extended attribute copy-up functionality added via 19472b6 ("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 <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent bfda63f commit 7c655be

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

security/selinux/hooks.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,9 +3533,10 @@ static int selinux_inode_copy_up_xattr(const char *name)
35333533
{
35343534
/* The copy_up hook above sets the initial context on an inode, but we
35353535
* don't then want to overwrite it by blindly copying all the lower
3536-
* xattrs up. Instead, we have to filter out SELinux-related xattrs.
3536+
* xattrs up. Instead, filter out SELinux-related xattrs following
3537+
* policy load.
35373538
*/
3538-
if (strcmp(name, XATTR_NAME_SELINUX) == 0)
3539+
if (selinux_initialized() && strcmp(name, XATTR_NAME_SELINUX) == 0)
35393540
return 1; /* Discard */
35403541
/*
35413542
* Any other attribute apart from SELINUX is not claimed, supported

0 commit comments

Comments
 (0)