KernelSU Bug: Sleeping Function Called From Invalid Context
in Post with 0 comment

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.

The article has been posted for too long and comments have been automatically closed.