Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysrq: Allow magic SysRq key functions to be disabled through Kconfig

Turn the initial value of sysctl kernel.sysrq (SYSRQ_DEFAULT_ENABLE)
into a Kconfig variable.

Original version by Bastian Blank <waldi@debian.org>.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ben Hutchings and committed by
Greg Kroah-Hartman
8eaede49 e8b5cbb0

+17 -12
+6 -7
Documentation/sysrq.txt
··· 11 11 You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when 12 12 configuring the kernel. When running a kernel with SysRq compiled in, 13 13 /proc/sys/kernel/sysrq controls the functions allowed to be invoked via 14 - the SysRq key. By default the file contains 1 which means that every 15 - possible SysRq request is allowed (in older versions SysRq was disabled 16 - by default, and you were required to specifically enable it at run-time 17 - but this is not the case any more). Here is the list of possible values 18 - in /proc/sys/kernel/sysrq: 14 + the SysRq key. The default value in this file is set by the 15 + CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE config symbol, which itself defaults 16 + to 1. Here is the list of possible values in /proc/sys/kernel/sysrq: 19 17 0 - disable sysrq completely 20 18 1 - enable all functions of sysrq 21 19 >1 - bitmask of allowed sysrq functions (see below for detailed function ··· 30 32 You can set the value in the file by the following command: 31 33 echo "number" >/proc/sys/kernel/sysrq 32 34 33 - The number may be written either as decimal or as hexadecimal with the 34 - 0x prefix. 35 + The number may be written here either as decimal or as hexadecimal 36 + with the 0x prefix. CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE must always be 37 + written in hexadecimal. 35 38 36 39 Note that the value of /proc/sys/kernel/sysrq influences only the invocation 37 40 via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always
+1 -1
drivers/tty/sysrq.c
··· 51 51 #include <asm/irq_regs.h> 52 52 53 53 /* Whether we react on sysrq keys or just ignore them */ 54 - static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 54 + static int __read_mostly sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; 55 55 static bool __read_mostly sysrq_always_enabled; 56 56 57 57 unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED };
-3
include/linux/sysrq.h
··· 17 17 #include <linux/errno.h> 18 18 #include <linux/types.h> 19 19 20 - /* Enable/disable SYSRQ support by default (0==no, 1==yes). */ 21 - #define SYSRQ_DEFAULT_ENABLE 1 22 - 23 20 /* Possible values of bitmask for enabling sysrq functions */ 24 21 /* 0x0001 is reserved for enable everything */ 25 22 #define SYSRQ_ENABLE_LOG 0x0002
+1 -1
kernel/sysctl.c
··· 190 190 191 191 #ifdef CONFIG_MAGIC_SYSRQ 192 192 /* Note: sysrq code uses it's own private copy */ 193 - static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 193 + static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; 194 194 195 195 static int sysrq_sysctl_handler(ctl_table *table, int write, 196 196 void __user *buffer, size_t *lenp,
+9
lib/Kconfig.debug
··· 312 312 keys are documented in <file:Documentation/sysrq.txt>. Don't say Y 313 313 unless you really know what this hack does. 314 314 315 + config MAGIC_SYSRQ_DEFAULT_ENABLE 316 + hex "Enable magic SysRq key functions by default" 317 + depends on MAGIC_SYSRQ 318 + default 0x1 319 + help 320 + Specifies which SysRq key functions are enabled by default. 321 + This may be set to 1 or 0 to enable or disable them all, or 322 + to a bitmask as described in Documentation/sysrq.txt. 323 + 315 324 config DEBUG_KERNEL 316 325 bool "Kernel debugging" 317 326 help