Re: [PATCH] tty: only print sysrq help for handlers that are enabled

From: Peter Hurley
Date: Tue Dec 24 2013 - 07:44:02 EST

On 12/24/2013 12:04 AM, shawn@xxxxxxxxxxxxxxx wrote:
On Tue, Dec 03, 2013 at 07:55:25AM -0800, Shawn Landden wrote:
Also print out a notice when sysrq is in selective mode.

Signed-off-by: Shawn Landden <shawn@xxxxxxxxxxxxxxx>
drivers/tty/sysrq.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index ce396ec..4eee0e4 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -548,9 +548,14 @@ void __handle_sysrq(int key, bool check_mask)
if (j != i)
- printk("%s ", sysrq_key_table[i]->help_msg);
+ /* only print if handler is enabled */
+ if (sysrq_enabled & 1 ||
+ sysrq_enabled & sysrq_key_table[i]->enable_mask)
+ printk("%s ", sysrq_key_table[i]->help_msg);
+ if (!(sysrq_enabled & 1))
+ printk("(some options are disabled)");
console_loglevel = orig_log_level;

What exactly is this fixing? What is broken here that this change
resolves? Where is it applicable? I need a lot more context here

Without this patch you get something like
re[b]oot [r]aw [s]ync [h]elp ....
even if none of these sysrq triggers are available because of the setting
mask of
With this patch then if (e.g.)
kernel.sysrq = 16
then you will only see
i.e. those commands you have privilege to issue via sysrq keypresses.
Contact me if you need more,

But all operations are enabled when triggered via /proc/sysrq-trigger.
How about indicating key-disabled operations with a symbol instead?

Peter Hurley

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at