Skip to content

Commit 89b223b

Browse files
committed
selinux: deprecate disabling SELinux and runtime
Deprecate the CONFIG_SECURITY_SELINUX_DISABLE functionality. The code was originally developed to make it easier for Linux distributions to support architectures where adding parameters to the kernel command line was difficult. Unfortunately, supporting runtime disable meant we had to make some security trade-offs when it came to the LSM hooks, as documented in the Kconfig help text: NOTE: selecting this option will disable the '__ro_after_init' kernel hardening feature for security hooks. Please consider using the selinux=0 boot parameter instead of enabling this option. Fortunately it looks as if that the original motivation for the runtime disable functionality is gone, and Fedora/RHEL appears to be the only major distribution enabling this capability at build time so we are now taking steps to remove it entirely from the kernel. The first step is to mark the functionality as deprecated and print an error when it is used (what this patch is doing). As Fedora/RHEL makes progress in transitioning the distribution away from runtime disable, we will introduce follow-up patches over several kernel releases which will block for increasing periods of time when the runtime disable is used. Finally we will remove the option entirely once we believe all users have moved to the kernel cmdline approach. Acked-by: Casey Schaufler <casey@schaufler-ca.com> Acked-by: Ondrej Mosnacek <omosnace@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 7a4b519 commit 89b223b

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
What: /sys/fs/selinux/disable
2+
Date: April 2005 (predates git)
3+
KernelVersion: 2.6.12-rc2 (predates git)
4+
Contact: selinux@vger.kernel.org
5+
Description:
6+
7+
The selinuxfs "disable" node allows SELinux to be disabled at runtime
8+
prior to a policy being loaded into the kernel. If disabled via this
9+
mechanism, SELinux will remain disabled until the system is rebooted.
10+
11+
The preferred method of disabling SELinux is via the "selinux=0" boot
12+
parameter, but the selinuxfs "disable" node was created to make it
13+
easier for systems with primitive bootloaders that did not allow for
14+
easy modification of the kernel command line. Unfortunately, allowing
15+
for SELinux to be disabled at runtime makes it difficult to secure the
16+
kernel's LSM hooks using the "__ro_after_init" feature.
17+
18+
Thankfully, the need for the SELinux runtime disable appears to be
19+
gone, the default Kconfig configuration disables this selinuxfs node,
20+
and only one of the major distributions, Fedora, supports disabling
21+
SELinux at runtime. Fedora is in the process of removing the
22+
selinuxfs "disable" node and once that is complete we will start the
23+
slow process of removing this code from the kernel.
24+
25+
More information on /sys/fs/selinux/disable can be found under the
26+
CONFIG_SECURITY_SELINUX_DISABLE Kconfig option.

‎MAINTAINERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14806,6 +14806,7 @@ F: include/uapi/linux/selinux_netlink.h
1480614806
F: security/selinux/
1480714807
F: scripts/selinux/
1480814808
F: Documentation/admin-guide/LSM/SELinux.rst
14809+
F: Documentation/ABI/obsolete/sysfs-selinux-disable
1480914810

1481014811
SENSABLE PHANTOM
1481114812
M: Jiri Slaby <jirislaby@gmail.com>

‎security/selinux/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ config SECURITY_SELINUX_DISABLE
4242
using the selinux=0 boot parameter instead of enabling this
4343
option.
4444

45+
WARNING: this option is deprecated and will be removed in a future
46+
kernel release.
47+
4548
If you are unsure how to answer this question, answer N.
4649

4750
config SECURITY_SELINUX_DEVELOP

‎security/selinux/selinuxfs.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
281281
int new_value;
282282
int enforcing;
283283

284+
/* NOTE: we are now officially considering runtime disable as
285+
* deprecated, and using it will become increasingly painful
286+
* (e.g. sleeping/blocking) as we progress through future
287+
* kernel releases until eventually it is removed
288+
*/
289+
pr_err("SELinux: Runtime disable is deprecated, use selinux=0 on the kernel cmdline.\n");
290+
284291
if (count >= PAGE_SIZE)
285292
return -ENOMEM;
286293

0 commit comments

Comments
 (0)