selinux: don't sleep when CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE is true
authorPaul Moore <paul@paul-moore.com>
Thu, 14 Apr 2022 20:40:10 +0000 (16:40 -0400)
committerPaul Moore <paul@paul-moore.com>
Thu, 14 Apr 2022 20:44:21 +0000 (16:44 -0400)
commit6a9e261cbbee08c499f2331910027e8c40c8f81f
tree9478231587f3a1750bf1a200c57997381f5e715e
parent81200b0265b15609dcecf192e3f7fb238ec0d3da
selinux: don't sleep when CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE is true

Unfortunately commit 81200b0265b1 ("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: 81200b0265b1 ("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>
security/selinux/include/security.h
security/selinux/selinuxfs.c