Skip to content

Commit 6a9e261

Browse files
committed
selinux: don't sleep when CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE is true
Unfortunately commit 81200b0 ("selinux: checkreqprot is deprecated, add some ssleep() discomfort") added a five second sleep during early kernel boot, e.g. start_kernel(), which could cause a "scheduling while atomic" panic. This patch fixes this problem by moving the sleep out of checkreqprot_set() and into sel_write_checkreqprot() so that we only sleep when the checkreqprot setting is set during runtime, after the kernel has booted. The error message remains the same in both cases. Fixes: 81200b0 ("selinux: checkreqprot is deprecated, add some ssleep() discomfort") Reported-by: J. Bruce Fields <bfields@fieldses.org> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 81200b0 commit 6a9e261

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

security/selinux/include/security.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ static inline bool checkreqprot_get(const struct selinux_state *state)
152152

153153
static inline void checkreqprot_set(struct selinux_state *state, bool value)
154154
{
155-
if (value) {
155+
if (value)
156156
pr_err("SELinux: https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-checkreqprot\n");
157-
ssleep(5);
158-
}
159157
WRITE_ONCE(state->checkreqprot, value);
160158
}
161159

security/selinux/selinuxfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
762762
}
763763

764764
checkreqprot_set(fsi->state, (new_value ? 1 : 0));
765+
if (new_value)
766+
ssleep(5);
765767
length = count;
766768

767769
selinux_ima_measure_state(fsi->state);

0 commit comments

Comments
 (0)