public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selinux: only filter copy-up xattrs following initialization
@ 2024-02-02  6:40 David Disseldorp
  2024-02-02 18:53 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: David Disseldorp @ 2024-02-02  6:40 UTC (permalink / raw)
  To: selinux; +Cc: linux-unionfs, David Disseldorp

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>
---
Changes since v1:
- drop RFC
- slightly rework commit message and preceeding comment

 security/selinux/hooks.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index a6bf90ace84c7..b17247d66b24f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3534,9 +3534,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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] selinux: only filter copy-up xattrs following  initialization
  2024-02-02  6:40 [PATCH v2] selinux: only filter copy-up xattrs following initialization David Disseldorp
@ 2024-02-02 18:53 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2024-02-02 18:53 UTC (permalink / raw)
  To: David Disseldorp, selinux; +Cc: linux-unionfs

On Feb  2, 2024 David Disseldorp <ddiss@suse.de> wrote:
> 
> 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>
> ---
> Changes since v1:
> - drop RFC
> - slightly rework commit message and preceeding comment
> 
>  security/selinux/hooks.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Merged into selinux/dev, thanks for following up on this.

--
paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-02 18:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02  6:40 [PATCH v2] selinux: only filter copy-up xattrs following initialization David Disseldorp
2024-02-02 18:53 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox