lkml.org 
[lkml]   [1999]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH] Slightly safer Magic SysRq
About 10 months ago, I hit Alt-PrintScrn-l two times too many, due to
poor memory, and I decided that my kernel would probably be better
without this (considering that according to the documentation, it's
guarenteed to kill the system), and so I patched my code.

Up until now, I've procrastinated on submitting this trivial patch due
to wanting to make absolutely sure it works; it's been tried on four x86
machines so far, but they don't make heavy use of Magic SysRq. No
problems found so far. Basically, my patch turns it into a synonym for
Alt-PrintScrn-i, although I've been tempted to disable it entirely, so
that noone would get in the habit of using the other option. (If people
provide me feedback, I may do the other method.) I've not patched it to
change documentation other than Configure.help, due to it being an
option.

Kernel 2.3.21 is the first I've tried that needs a different patch,
although I've not kept up, so I'm sure there are a bunch in the 2.3.x
series (2.2.13-pre14 worked fine), so I've made a second patch.

Due to Pine's "helpful" use of base64 for text attachments, I'm also
including both patches in the text portion, but the attachments should
work fine for people who can handle it.

Ed Grimm

---cut here--- safesysrq.patch (2.2.0-2.2.13-pre14)
diff -ru linux/Documentation/Configure.help edpre5/Documentation/Configure.help
--- linux/Documentation/Configure.help Thu Jan 7 14:05:16 1999
+++ edpre5/Documentation/Configure.help Fri Jan 8 11:55:33 1999
@@ -9286,6 +9286,14 @@
keys are documented in Documentation/sysrq.txt. Don't say Y unless
you really know what this hack does.

+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,
+ leaving you with a (barely) usable system. This can be helpful to
+ those who don't use sysrq very often, and don't want to accidentally
+ completely cripple their system, when they were just trying to get rid
+ of a runaway process or something.
+
ISDN subsystem
CONFIG_ISDN
ISDN ("Integrated Services Digital Networks", called RNIS in France)
diff -ru linux/arch/i386/config.in edpre5/arch/i386/config.in
--- linux/arch/i386/config.in Thu Jan 7 14:05:17 1999
+++ edpre5/arch/i386/config.in Fri Jan 8 11:48:04 1999
@@ -186,5 +186,8 @@

#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+if [ "$CONFIG_MAGIC_SYSRQ" != "n" ]; then
+ bool 'Disable SysRq l key' CONFIG_SAFE_MAGIC_SYSRQ
+fi
endmenu

diff -ru linux/drivers/char/sysrq.c edpre5/drivers/char/sysrq.c
--- linux/drivers/char/sysrq.c Wed Nov 25 20:25:17 1998
+++ edpre5/drivers/char/sysrq.c Fri Jan 8 11:50:37 1999
@@ -41,8 +41,10 @@

for_each_task(p) {
if (p->pid && p->mm != &init_mm) { /* Not swapper nor kernel thread */
+#ifndef CONFIG_SAFE_MAGIC_SYSRQ
if (p->pid == 1 && even_init) /* Ugly hack to kill init */
p->pid = 0x8000;
+#endif
force_sig(sig, p);
}
}
---cut here--- safesysrq.patch (2.2.0-2.2.13-pre14)
---cut here--- safesysrq.patch (2.3.21)
--- linux-2.3.21/Documentation/Configure.help Sat Oct 9 20:51:41 1999
+++ linux-2.3.21.safesysrq/Documentation/Configure.help Tue Oct 12 19:58:08 1999
@@ -10774,8 +10774,16 @@
by pressing various keys while holding SysRq (Alt+PrintScreen). The
keys are documented in Documentation/sysrq.txt. Don't say Y unless
you really know what this hack does.

+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,
+ leaving you with a (barely) usable system. This can be helpful to
+ those who don't use sysrq very often, and don't want to accidentally
+ completely cripple their system, when they were just trying to get rid
+ of a runaway process or something.
+
ISDN subsystem
CONFIG_ISDN
ISDN ("Integrated Services Digital Networks", called RNIS in France)
is a special type of fully digital telephone service; it's mostly
--- linux-2.3.21/arch/i386/config.in Mon Oct 11 12:37:44 1999
+++ linux-2.3.21.safesysrq/arch/i386/config.in Tue Oct 12 19:58:08 1999
@@ -201,6 +201,9 @@
comment 'Kernel hacking'

#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+if [ "$CONFIG_MAGIC_SYSRQ" != "n" ]; then
+ bool 'Disable SysRq l key' CONFIG_SAFE_MAGIC_SYSRQ
+fi
endmenu

--- linux-2.3.21/drivers/char/sysrq.c Tue Jul 20 01:08:41 1999
+++ linux-2.3.21.safesysrq/drivers/char/sysrq.c Tue Oct 12 20:01:07 1999
@@ -42,10 +42,12 @@
struct task_struct *p;

for_each_task(p) {
if (p->mm) { /* Not swapper nor kernel thread */
+#ifndef CONFIG_SAFE_MAGIC_SYSRQ
if (p->pid == 1 && even_init) /* Ugly hack to kill init */
p->pid = 0x8000;
+#endif
force_sig(sig, p);
}
}
}
---cut here--- safesysrq.patch (2.3.21)diff -ru linux/Documentation/Configure.help edpre5/Documentation/Configure.help
--- linux/Documentation/Configure.help Thu Jan 7 14:05:16 1999
+++ edpre5/Documentation/Configure.help Fri Jan 8 11:55:33 1999
@@ -9286,6 +9286,14 @@
keys are documented in Documentation/sysrq.txt. Don't say Y unless
you really know what this hack does.

+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,
+ leaving you with a (barely) usable system. This can be helpful to
+ those who don't use sysrq very often, and don't want to accidentally
+ completely cripple their system, when they were just trying to get rid
+ of a runaway process or something.
+
ISDN subsystem
CONFIG_ISDN
ISDN ("Integrated Services Digital Networks", called RNIS in France)
diff -ru linux/arch/i386/config.in edpre5/arch/i386/config.in
--- linux/arch/i386/config.in Thu Jan 7 14:05:17 1999
+++ edpre5/arch/i386/config.in Fri Jan 8 11:48:04 1999
@@ -186,5 +186,8 @@

#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+if [ "$CONFIG_MAGIC_SYSRQ" != "n" ]; then
+ bool 'Disable SysRq l key' CONFIG_SAFE_MAGIC_SYSRQ
+fi
endmenu

diff -ru linux/drivers/char/sysrq.c edpre5/drivers/char/sysrq.c
--- linux/drivers/char/sysrq.c Wed Nov 25 20:25:17 1998
+++ edpre5/drivers/char/sysrq.c Fri Jan 8 11:50:37 1999
@@ -41,8 +41,10 @@

for_each_task(p) {
if (p->pid && p->mm != &init_mm) { /* Not swapper nor kernel thread */
+#ifndef CONFIG_SAFE_MAGIC_SYSRQ
if (p->pid == 1 && even_init) /* Ugly hack to kill init */
p->pid = 0x8000;
+#endif
force_sig(sig, p);
}
}--- linux-2.3.21/Documentation/Configure.help Sat Oct 9 20:51:41 1999
+++ linux-2.3.21.safesysrq/Documentation/Configure.help Tue Oct 12 19:58:08 1999
@@ -10774,8 +10774,16 @@
by pressing various keys while holding SysRq (Alt+PrintScreen). The
keys are documented in Documentation/sysrq.txt. Don't say Y unless
you really know what this hack does.

+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,
+ leaving you with a (barely) usable system. This can be helpful to
+ those who don't use sysrq very often, and don't want to accidentally
+ completely cripple their system, when they were just trying to get rid
+ of a runaway process or something.
+
ISDN subsystem
CONFIG_ISDN
ISDN ("Integrated Services Digital Networks", called RNIS in France)
is a special type of fully digital telephone service; it's mostly
--- linux-2.3.21/arch/i386/config.in Mon Oct 11 12:37:44 1999
+++ linux-2.3.21.safesysrq/arch/i386/config.in Tue Oct 12 19:58:08 1999
@@ -201,6 +201,9 @@
comment 'Kernel hacking'

#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+if [ "$CONFIG_MAGIC_SYSRQ" != "n" ]; then
+ bool 'Disable SysRq l key' CONFIG_SAFE_MAGIC_SYSRQ
+fi
endmenu

--- linux-2.3.21/drivers/char/sysrq.c Tue Jul 20 01:08:41 1999
+++ linux-2.3.21.safesysrq/drivers/char/sysrq.c Tue Oct 12 20:01:07 1999
@@ -42,10 +42,12 @@
struct task_struct *p;

for_each_task(p) {
if (p->mm) { /* Not swapper nor kernel thread */
+#ifndef CONFIG_SAFE_MAGIC_SYSRQ
if (p->pid == 1 && even_init) /* Ugly hack to kill init */
p->pid = 0x8000;
+#endif
force_sig(sig, p);
}
}
}
\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.065 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site