Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysrq: Use panic() to force a crash

sysrq_handle_crash() currently forces a crash by dereferencing a
NULL pointer, which is undefined behavior in C. Just call panic()
instead, which is simpler and doesn't depend on compiler specific
handling of the undefined behavior.

Remove the comment on why the RCU lock needs to be released, it isn't
accurate anymore since the crash now isn't handled by the page fault
handler (for reference: the comment was added by commit 984cf355aeaa
("sysrq: Fix warning in sysrq generated crash.")). Releasing the lock
is still good practice though.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Matthias Kaehlcke and committed by
Greg Kroah-Hartman
8341f2f2 279070b9

+3 -10
+3 -10
drivers/tty/sysrq.c
··· 134 134 135 135 static void sysrq_handle_crash(int key) 136 136 { 137 - char *killer = NULL; 138 - 139 - /* we need to release the RCU read lock here, 140 - * otherwise we get an annoying 141 - * 'BUG: sleeping function called from invalid context' 142 - * complaint from the kernel before the panic. 143 - */ 137 + /* release the RCU read lock before crashing */ 144 138 rcu_read_unlock(); 145 - panic_on_oops = 1; /* force panic */ 146 - wmb(); 147 - *killer = 1; 139 + 140 + panic("sysrq triggered crash\n"); 148 141 } 149 142 static struct sysrq_key_op sysrq_crash_op = { 150 143 .handler = sysrq_handle_crash,