Commit f9deb9e6 authored by Russell King's avatar Russell King Committed by Kai Germaschewski

[PATCH] 2.4 and 2.5: remove Alt-Sysrq-L

The following patch removes Alt-Sysrq-L and its associated hack to kill
of PID1, the init process.  This is a mis-feature.

If PID1 is killed, the kernel immediately enters an infinite loop in the
depths of do_exit() with interrupts disabled, completely locking the
machine.  Obviously you can only reach for the reset button or power
switch after this, leaving you with dirty filesystems.
parent be4808e0
...@@ -284,24 +284,20 @@ static struct sysrq_key_op sysrq_showmem_op = { ...@@ -284,24 +284,20 @@ static struct sysrq_key_op sysrq_showmem_op = {
/* signal sysrq helper function /* signal sysrq helper function
* Sends a signal to all user processes */ * Sends a signal to all user processes */
static void send_sig_all(int sig, int even_init) static void send_sig_all(int sig)
{ {
struct task_struct *p; struct task_struct *p;
for_each_task(p) { for_each_task(p) {
if (p->mm) { /* Not swapper nor kernel thread */ if (p->mm && p->pid != 1)
if (p->pid == 1 && even_init) /* Not swapper, init nor kernel thread */
/* Ugly hack to kill init */ force_sig(sig, p);
p->pid = 0x8000;
if (p->pid != 1)
force_sig(sig, p);
}
} }
} }
static void sysrq_handle_term(int key, struct pt_regs *pt_regs, static void sysrq_handle_term(int key, struct pt_regs *pt_regs,
struct kbd_struct *kbd, struct tty_struct *tty) { struct kbd_struct *kbd, struct tty_struct *tty) {
send_sig_all(SIGTERM, 0); send_sig_all(SIGTERM);
console_loglevel = 8; console_loglevel = 8;
} }
static struct sysrq_key_op sysrq_term_op = { static struct sysrq_key_op sysrq_term_op = {
...@@ -312,7 +308,7 @@ static struct sysrq_key_op sysrq_term_op = { ...@@ -312,7 +308,7 @@ static struct sysrq_key_op sysrq_term_op = {
static void sysrq_handle_kill(int key, struct pt_regs *pt_regs, static void sysrq_handle_kill(int key, struct pt_regs *pt_regs,
struct kbd_struct *kbd, struct tty_struct *tty) { struct kbd_struct *kbd, struct tty_struct *tty) {
send_sig_all(SIGKILL, 0); send_sig_all(SIGKILL);
console_loglevel = 8; console_loglevel = 8;
} }
static struct sysrq_key_op sysrq_kill_op = { static struct sysrq_key_op sysrq_kill_op = {
...@@ -321,17 +317,6 @@ static struct sysrq_key_op sysrq_kill_op = { ...@@ -321,17 +317,6 @@ static struct sysrq_key_op sysrq_kill_op = {
action_msg: "Kill All Tasks", action_msg: "Kill All Tasks",
}; };
static void sysrq_handle_killall(int key, struct pt_regs *pt_regs,
struct kbd_struct *kbd, struct tty_struct *tty) {
send_sig_all(SIGKILL, 1);
console_loglevel = 8;
}
static struct sysrq_key_op sysrq_killall_op = {
handler: sysrq_handle_killall,
help_msg: "killalL",
action_msg: "Kill All Tasks (even init)",
};
/* END SIGNAL SYSRQ HANDLERS BLOCK */ /* END SIGNAL SYSRQ HANDLERS BLOCK */
...@@ -366,7 +351,7 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = { ...@@ -366,7 +351,7 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
#else #else
/* k */ NULL, /* k */ NULL,
#endif #endif
/* l */ &sysrq_killall_op, /* l */ NULL,
/* m */ &sysrq_showmem_op, /* m */ &sysrq_showmem_op,
/* n */ NULL, /* n */ NULL,
/* o */ NULL, /* This will often be registered /* o */ NULL, /* This will often be registered
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment