A bug has been identified in KernelSU that results in a kernel panic during boot when CONFIG_DEBUG_ATOMIC_SLEEP is enabled in the kernel. The issue stems from a call to `hashtab_insert()` within the SELinux module, which triggers a sleep using `cond_resched()`. This call disrupts the execution flow within KernelSU when `apply_kernelsu_rules()` is invoked, ultimately causing a "sleeping function called from invalid context" error. The problematic code executes `rcu_read_lock()` inside `apply_kernelsu_rules()`, which is not permissible when KernelSU is in the process of sleep.
The error occurs during the "second_stage" execution of `init`, specifically when `apply_kernelsu_rules()` is called. During this stage, KernelSU attempts to apply its rules and modify the system's file context. The combination of KernelSU's execution flow and the SELinux sleep function leads to a deadlock situation resulting in the kernel panic.
This article is created by nurl and is licensed under the Creative Commons Attribution 4.0 International License.
All articles on this site, unless otherwise specified as reprints or sources, are either original works or translations by this site. Please ensure proper attribution before reprinting.