diff options
-rw-r--r-- | Documentation/kernel-parameters.txt | 6 | ||||
-rw-r--r-- | drivers/char/sysrq.c | 37 | ||||
-rw-r--r-- | drivers/char/viocons.c | 10 | ||||
-rw-r--r-- | include/linux/sysrq.h | 22 | ||||
-rw-r--r-- | kernel/sysctl.c | 3 |
5 files changed, 60 insertions, 18 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index d8323b8893c3..ef69c75780bf 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1656,6 +1656,12 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1656 | sym53c416= [HW,SCSI] | 1656 | sym53c416= [HW,SCSI] |
1657 | See header of drivers/scsi/sym53c416.c. | 1657 | See header of drivers/scsi/sym53c416.c. |
1658 | 1658 | ||
1659 | sysrq_always_enabled | ||
1660 | [KNL] | ||
1661 | Ignore sysrq setting - this boot parameter will | ||
1662 | neutralize any effect of /proc/sys/kernel/sysrq. | ||
1663 | Useful for debugging. | ||
1664 | |||
1659 | t128= [HW,SCSI] | 1665 | t128= [HW,SCSI] |
1660 | See header of drivers/scsi/t128.c. | 1666 | See header of drivers/scsi/t128.c. |
1661 | 1667 | ||
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 05810c8d20bc..13935235e066 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -41,7 +41,34 @@ | |||
41 | #include <asm/irq_regs.h> | 41 | #include <asm/irq_regs.h> |
42 | 42 | ||
43 | /* Whether we react on sysrq keys or just ignore them */ | 43 | /* Whether we react on sysrq keys or just ignore them */ |
44 | int sysrq_enabled = 1; | 44 | int __read_mostly __sysrq_enabled = 1; |
45 | |||
46 | static int __read_mostly sysrq_always_enabled; | ||
47 | |||
48 | int sysrq_on(void) | ||
49 | { | ||
50 | return __sysrq_enabled || sysrq_always_enabled; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * A value of 1 means 'all', other nonzero values are an op mask: | ||
55 | */ | ||
56 | static inline int sysrq_on_mask(int mask) | ||
57 | { | ||
58 | return sysrq_always_enabled || __sysrq_enabled == 1 || | ||
59 | (__sysrq_enabled & mask); | ||
60 | } | ||
61 | |||
62 | static int __init sysrq_always_enabled_setup(char *str) | ||
63 | { | ||
64 | sysrq_always_enabled = 1; | ||
65 | printk(KERN_INFO "debug: sysrq always enabled.\n"); | ||
66 | |||
67 | return 1; | ||
68 | } | ||
69 | |||
70 | __setup("sysrq_always_enabled", sysrq_always_enabled_setup); | ||
71 | |||
45 | 72 | ||
46 | static void sysrq_handle_loglevel(int key, struct tty_struct *tty) | 73 | static void sysrq_handle_loglevel(int key, struct tty_struct *tty) |
47 | { | 74 | { |
@@ -379,8 +406,7 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) | |||
379 | * Should we check for enabled operations (/proc/sysrq-trigger | 406 | * Should we check for enabled operations (/proc/sysrq-trigger |
380 | * should not) and is the invoked operation enabled? | 407 | * should not) and is the invoked operation enabled? |
381 | */ | 408 | */ |
382 | if (!check_mask || sysrq_enabled == 1 || | 409 | if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { |
383 | (sysrq_enabled & op_p->enable_mask)) { | ||
384 | printk("%s\n", op_p->action_msg); | 410 | printk("%s\n", op_p->action_msg); |
385 | console_loglevel = orig_log_level; | 411 | console_loglevel = orig_log_level; |
386 | op_p->handler(key, tty); | 412 | op_p->handler(key, tty); |
@@ -414,9 +440,8 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) | |||
414 | */ | 440 | */ |
415 | void handle_sysrq(int key, struct tty_struct *tty) | 441 | void handle_sysrq(int key, struct tty_struct *tty) |
416 | { | 442 | { |
417 | if (!sysrq_enabled) | 443 | if (sysrq_on()) |
418 | return; | 444 | __handle_sysrq(key, tty, 1); |
419 | __handle_sysrq(key, tty, 1); | ||
420 | } | 445 | } |
421 | EXPORT_SYMBOL(handle_sysrq); | 446 | EXPORT_SYMBOL(handle_sysrq); |
422 | 447 | ||
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c index 6d2e314860df..0e0da443cbd5 100644 --- a/drivers/char/viocons.c +++ b/drivers/char/viocons.c | |||
@@ -61,10 +61,7 @@ | |||
61 | static DEFINE_SPINLOCK(consolelock); | 61 | static DEFINE_SPINLOCK(consolelock); |
62 | static DEFINE_SPINLOCK(consoleloglock); | 62 | static DEFINE_SPINLOCK(consoleloglock); |
63 | 63 | ||
64 | #ifdef CONFIG_MAGIC_SYSRQ | ||
65 | static int vio_sysrq_pressed; | 64 | static int vio_sysrq_pressed; |
66 | extern int sysrq_enabled; | ||
67 | #endif | ||
68 | 65 | ||
69 | #define VIOCHAR_NUM_BUF 16 | 66 | #define VIOCHAR_NUM_BUF 16 |
70 | 67 | ||
@@ -936,8 +933,10 @@ static void vioHandleData(struct HvLpEvent *event) | |||
936 | */ | 933 | */ |
937 | num_pushed = 0; | 934 | num_pushed = 0; |
938 | for (index = 0; index < cevent->len; index++) { | 935 | for (index = 0; index < cevent->len; index++) { |
939 | #ifdef CONFIG_MAGIC_SYSRQ | 936 | /* |
940 | if (sysrq_enabled) { | 937 | * Will be optimized away if !CONFIG_MAGIC_SYSRQ: |
938 | */ | ||
939 | if (sysrq_on()) { | ||
941 | /* 0x0f is the ascii character for ^O */ | 940 | /* 0x0f is the ascii character for ^O */ |
942 | if (cevent->data[index] == '\x0f') { | 941 | if (cevent->data[index] == '\x0f') { |
943 | vio_sysrq_pressed = 1; | 942 | vio_sysrq_pressed = 1; |
@@ -956,7 +955,6 @@ static void vioHandleData(struct HvLpEvent *event) | |||
956 | continue; | 955 | continue; |
957 | } | 956 | } |
958 | } | 957 | } |
959 | #endif | ||
960 | /* | 958 | /* |
961 | * The sysrq sequence isn't included in this check if | 959 | * The sysrq sequence isn't included in this check if |
962 | * sysrq is enabled and compiled into the kernel because | 960 | * sysrq is enabled and compiled into the kernel because |
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 9df8833670cb..98a1d8cfb73d 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h | |||
@@ -37,23 +37,37 @@ struct sysrq_key_op { | |||
37 | 37 | ||
38 | #ifdef CONFIG_MAGIC_SYSRQ | 38 | #ifdef CONFIG_MAGIC_SYSRQ |
39 | 39 | ||
40 | extern int sysrq_on(void); | ||
41 | |||
42 | /* | ||
43 | * Do not use this one directly: | ||
44 | */ | ||
45 | extern int __sysrq_enabled; | ||
46 | |||
40 | /* Generic SysRq interface -- you may call it from any device driver, supplying | 47 | /* Generic SysRq interface -- you may call it from any device driver, supplying |
41 | * ASCII code of the key, pointer to registers and kbd/tty structs (if they | 48 | * ASCII code of the key, pointer to registers and kbd/tty structs (if they |
42 | * are available -- else NULL's). | 49 | * are available -- else NULL's). |
43 | */ | 50 | */ |
44 | 51 | ||
45 | void handle_sysrq(int, struct tty_struct *); | 52 | void handle_sysrq(int key, struct tty_struct *tty); |
46 | void __handle_sysrq(int, struct tty_struct *, int check_mask); | 53 | void __handle_sysrq(int key, struct tty_struct *tty, int check_mask); |
47 | int register_sysrq_key(int, struct sysrq_key_op *); | 54 | int register_sysrq_key(int key, struct sysrq_key_op *op); |
48 | int unregister_sysrq_key(int, struct sysrq_key_op *); | 55 | int unregister_sysrq_key(int key, struct sysrq_key_op *op); |
49 | struct sysrq_key_op *__sysrq_get_key_op(int key); | 56 | struct sysrq_key_op *__sysrq_get_key_op(int key); |
50 | 57 | ||
51 | #else | 58 | #else |
52 | 59 | ||
60 | static inline int sysrq_on(void) | ||
61 | { | ||
62 | return 0; | ||
63 | } | ||
53 | static inline int __reterr(void) | 64 | static inline int __reterr(void) |
54 | { | 65 | { |
55 | return -EINVAL; | 66 | return -EINVAL; |
56 | } | 67 | } |
68 | static inline void handle_sysrq(int key, struct tty_struct *tty) | ||
69 | { | ||
70 | } | ||
57 | 71 | ||
58 | #define register_sysrq_key(ig,nore) __reterr() | 72 | #define register_sysrq_key(ig,nore) __reterr() |
59 | #define unregister_sysrq_key(ig,nore) __reterr() | 73 | #define unregister_sysrq_key(ig,nore) __reterr() |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 130c5ec9ee0b..600b33358ded 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -65,7 +65,6 @@ extern int sysctl_overcommit_memory; | |||
65 | extern int sysctl_overcommit_ratio; | 65 | extern int sysctl_overcommit_ratio; |
66 | extern int sysctl_panic_on_oom; | 66 | extern int sysctl_panic_on_oom; |
67 | extern int max_threads; | 67 | extern int max_threads; |
68 | extern int sysrq_enabled; | ||
69 | extern int core_uses_pid; | 68 | extern int core_uses_pid; |
70 | extern int suid_dumpable; | 69 | extern int suid_dumpable; |
71 | extern char core_pattern[]; | 70 | extern char core_pattern[]; |
@@ -543,7 +542,7 @@ static ctl_table kern_table[] = { | |||
543 | { | 542 | { |
544 | .ctl_name = KERN_SYSRQ, | 543 | .ctl_name = KERN_SYSRQ, |
545 | .procname = "sysrq", | 544 | .procname = "sysrq", |
546 | .data = &sysrq_enabled, | 545 | .data = &__sysrq_enabled, |
547 | .maxlen = sizeof (int), | 546 | .maxlen = sizeof (int), |
548 | .mode = 0644, | 547 | .mode = 0644, |
549 | .proc_handler = &proc_dointvec, | 548 | .proc_handler = &proc_dointvec, |