summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorStephen Smalley <stephen.smalley.work@gmail.com>2020-08-20 19:00:40 +0200
committerPaul Moore <paul@paul-moore.com>2020-08-21 03:55:31 +0200
commit9530a3e00459cd6eabf050133205e0e8fecbdfc7 (patch)
tree6694cacf7d7ec810637e34ce4473f631a2d05c79 /security
parentselinux: fix memdup.cocci warnings (diff)
downloadlinux-9530a3e00459cd6eabf050133205e0e8fecbdfc7.tar.xz
linux-9530a3e00459cd6eabf050133205e0e8fecbdfc7.zip
selinux: permit removing security.selinux xattr before policy load
Currently SELinux denies attempts to remove the security.selinux xattr always, even when permissive or no policy is loaded. This was originally motivated by the view that all files should be labeled, even if that label is unlabeled_t, and we shouldn't permit files that were once labeled to have their labels removed entirely. This however prevents removing SELinux xattrs in the case where one "disables" SELinux by not loading a policy (e.g. a system where runtime disable is removed and selinux=0 was not specified). Allow removing the xattr before SELinux is initialized. We could conceivably permit it even after initialization if permissive, or introduce a separate permission check here. Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index ca901025802a..89d3753b7bd5 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3271,6 +3271,9 @@ static int selinux_inode_removexattr(struct dentry *dentry, const char *name)
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
}
+ if (!selinux_initialized(&selinux_state))
+ return 0;
+
/* No one is allowed to remove a SELinux security label.
You can change the label, but all data must be labeled. */
return -EACCES;