Skip to content

Commit 8341f2f

Browse files
mkaehlckegregkh
authored andcommitted
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 984cf35 ("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>
1 parent 279070b commit 8341f2f

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎drivers/tty/sysrq.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,10 @@ static struct sysrq_key_op sysrq_unraw_op = {
134134

135135
static void sysrq_handle_crash(int key)
136136
{
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 */
144138
rcu_read_unlock();
145-
panic_on_oops = 1; /* force panic */
146-
wmb();
147-
*killer = 1;
139+
140+
panic("sysrq triggered crash\n");
148141
}
149142
static struct sysrq_key_op sysrq_crash_op = {
150143
.handler = sysrq_handle_crash,

0 commit comments

Comments
 (0)