[PATCH] Slightly safer Magic SysRq attempt2

Ed Grimm (tgape@bigfoot.com)
Mon, 25 Oct 1999 21:06:22 -0500 (EST)


On Wed, 13 Oct 1999, Guest section DW wrote:
> From: David Weinehall <tao@acc.umu.se>
>
>]>> +Safe Magic System Request Key support
>]>> +CONFIG_SAFE_MAGIC_SYSRQ
>]>> + If you say Y here, alt-SysRq-l will behave the same as alt-SysRq-i,
>]>
>]> Such things lead to a proliferation of CONFIG options.
>]> SYSRQ is already a very unimportant auxiliary option -
>]> I don't think it is a good idea to start offering this option
>]> in various subversions.
>
>] I've made a patch that makes all of the individual options for SysRQ into
>] sysctl's. However Alan somehow didn't like it, so it never got into the
>] kernel. I never got an explanation.
>
> Yes, a well-known complaint. In this case I agree with Alan.
> Of course I have no idea of Alan's reasoning, but mine would say:
> (i) SysRq is a wart that some people like, so it exists, but it is certainly
> not an official part of the Linux API. Such a wart must be very localized
> in the source code. It must not grow and develop sub-warts or cause
> changes elsewhere in the code.
> (ii) The reason SysRq exists is that people want to use the keyboard in some
> emergency cases, when something went very wrong. It is a human interface,
> not a software interface.

Ok, if a wart it be, then maybe you'd prefer an elimination of 7 lines
of wart and 3 lines documenting wart? These patches remove the
offending option utterly.

Btw, for the one or two people who might possibly care, the cuttoff is
somewhere before 2.3.19.

I've been running this since the 13th, and haven't had any problems.
Not that I'd expect them....

Ed Grimm

-----------begin cut here: patch for older kernels
--- linux/Documentation/sysrq.txt Wed Nov 25 20:25:17 1998
+++ edpre5/Documentation/sysrq.txt Wed Oct 13 21:29:21 1999
@@ -54,11 +54,8 @@
'e' - Send a SIGTERM to all processes, except for init.

'i' - Send a SIGKILL to all processes, except for init.

-'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system
- will be non-functional after this.)
-
* Okay, so what can I use them for?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well, un'R'aw is very handy when your X server or a svgalib program crashes.

--- linux/drivers/char/sysrq.c Wed Nov 25 20:25:17 1998
+++ edpre5/drivers/char/sysrq.c Wed Oct 13 21:14:00 1999
@@ -42,10 +42,8 @@
struct task_struct *p;

for_each_task(p) {
if (p->pid && p->mm != &init_mm) { /* Not swapper nor kernel thread */
- if (p->pid == 1 && even_init) /* Ugly hack to kill init */
- p->pid = 0x8000;
force_sig(sig, p);
}
}
}
@@ -124,13 +122,8 @@
break;
case 'i': /* I -- kill all user processes */
printk("Kill All Tasks\n");
send_sig_all(SIGKILL, 0);
- orig_log_level = 8;
- break;
- case 'l': /* L -- kill all processes including init */
- printk("Kill ALL Tasks (even init)\n");
- send_sig_all(SIGKILL, 1);
orig_log_level = 8;
break;
default: /* Unknown: help */
if (kbd)
-----------end cut here: patch for older kernels

-----------begin cut here: patch for newer kernels
--- linux-2.3.21/Documentation/sysrq.txt Wed Oct 13 21:28:57 1999
+++ linux-2.3.21.safesysrq/Documentation/sysrq.txt Wed Oct 13 21:29:21 1999
@@ -54,11 +54,8 @@
'e' - Send a SIGTERM to all processes, except for init.

'i' - Send a SIGKILL to all processes, except for init.

-'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system
- will be non-functional after this.)
-
* Okay, so what can I use them for?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well, un'R'aw is very handy when your X server or a svgalib program crashes.

--- linux-2.3.21/drivers/char/sysrq.c Tue Oct 12 22:24:09 1999
+++ linux-2.3.21.safesysrq/drivers/char/sysrq.c Wed Oct 13 21:14:00 1999
@@ -42,10 +42,8 @@
struct task_struct *p;

for_each_task(p) {
if (p->mm) { /* Not swapper nor kernel thread */
- if (p->pid == 1 && even_init) /* Ugly hack to kill init */
- p->pid = 0x8000;
force_sig(sig, p);
}
}
}
@@ -124,13 +122,8 @@
break;
case 'i': /* I -- kill all user processes */
printk("Kill All Tasks\n");
send_sig_all(SIGKILL, 0);
- orig_log_level = 8;
- break;
- case 'l': /* L -- kill all processes including init */
- printk("Kill ALL Tasks (even init)\n");
- send_sig_all(SIGKILL, 1);
orig_log_level = 8;
break;
default: /* Unknown: help */
if (kbd)
-----------end cut here: patch for newer kernels

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/