Skip to content

Commit 81200b0

Browse files
committed
selinux: checkreqprot is deprecated, add some ssleep() discomfort
The checkreqprot functionality was disabled by default back in Linux v4.4 (2015) with commit 2a35d19 ("selinux: change CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE default") and it was officially marked as deprecated in Linux v5.7. It was always a bit of a hack to workaround very old userspace and to the best of our knowledge, the checkreqprot functionality has been disabled by Linux distributions for quite some time. This patch moves the deprecation messages from KERN_WARNING to KERN_ERR and adds a five second sleep to anyone using it to help draw their attention to the deprecation and provide a URL which helps explain things in more detail. Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 43b6666 commit 81200b0

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

security/selinux/hooks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int __init checkreqprot_setup(char *str)
145145
if (!kstrtoul(str, 0, &checkreqprot)) {
146146
selinux_checkreqprot_boot = checkreqprot ? 1 : 0;
147147
if (checkreqprot)
148-
pr_warn("SELinux: checkreqprot set to 1 via kernel parameter. This is deprecated and will be rejected in a future kernel release.\n");
148+
pr_err("SELinux: checkreqprot set to 1 via kernel parameter. This is deprecated and will be rejected in a future kernel release.\n");
149149
}
150150
return 1;
151151
}
@@ -7293,6 +7293,8 @@ static __init int selinux_init(void)
72937293

72947294
memset(&selinux_state, 0, sizeof(selinux_state));
72957295
enforcing_set(&selinux_state, selinux_enforcing_boot);
7296+
if (CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE)
7297+
pr_err("SELinux: CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE is non-zero. This is deprecated and will be rejected in a future kernel release.\n");
72967298
checkreqprot_set(&selinux_state, selinux_checkreqprot_boot);
72977299
selinux_avc_init(&selinux_state.avc);
72987300
mutex_init(&selinux_state.status_lock);

security/selinux/include/security.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/rcupdate.h>
1717
#include <linux/refcount.h>
1818
#include <linux/workqueue.h>
19+
#include <linux/delay.h>
20+
#include <linux/printk.h>
1921
#include "flask.h"
2022
#include "policycap.h"
2123

@@ -150,6 +152,10 @@ static inline bool checkreqprot_get(const struct selinux_state *state)
150152

151153
static inline void checkreqprot_set(struct selinux_state *state, bool value)
152154
{
155+
if (value) {
156+
pr_err("SELinux: https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-checkreqprot\n");
157+
ssleep(5);
158+
}
153159
WRITE_ONCE(state->checkreqprot, value);
154160
}
155161

security/selinux/selinuxfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
757757
char comm[sizeof(current->comm)];
758758

759759
memcpy(comm, current->comm, sizeof(comm));
760-
pr_warn_once("SELinux: %s (%d) set checkreqprot to 1. This is deprecated and will be rejected in a future kernel release.\n",
761-
comm, current->pid);
760+
pr_err("SELinux: %s (%d) set checkreqprot to 1. This is deprecated and will be rejected in a future kernel release.\n",
761+
comm, current->pid);
762762
}
763763

764764
checkreqprot_set(fsi->state, (new_value ? 1 : 0));

0 commit comments

Comments
 (0)