linux-stable/include/linux/sysrq.h
Dmitry Safonov eaee41727e sysctl/sysrq: Remove __sysrq_enabled copy
Many embedded boards have a disconnected TTL level serial which can
generate some garbage that can lead to spurious false sysrq detects.

Currently, sysrq can be either completely disabled for serial console
or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
commit 732dbf3a61 ("serial: do not accept sysrq characters via serial port")

At Arista, we have such boards that can generate BREAK and random
garbage. While disabling sysrq for serial console would solve
the problem with spurious false sysrq triggers, it's also desirable
to have a way to enable sysrq back.

Having the way to enable sysrq was beneficial to debug lockups with
a manual investigation in field and on the other side preventing false
sysrq detections.

As a preparation to add sysrq_toggle_support() call into uart,
remove a private copy of sysrq_enabled from sysctl - it should reflect
the actual status of sysrq.

Furthermore, the private copy isn't correct already in case
sysrq_always_enabled is true. So, remove __sysrq_enabled and use a
getter-helper sysrq_mask() to check sysrq_key_op enabled status.

Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
Link: https://lore.kernel.org/r/20200302175135.269397-2-dima@arista.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-07 09:52:02 +01:00

83 lines
1.9 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/* -*- linux-c -*-
*
* $Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
*
* Linux Magic System Request Key Hacks
*
* (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*
* (c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
* overhauled to use key registration
* based upon discusions in irc://irc.openprojects.net/#kernelnewbies
*/
#ifndef _LINUX_SYSRQ_H
#define _LINUX_SYSRQ_H
#include <linux/errno.h>
#include <linux/types.h>
/* Possible values of bitmask for enabling sysrq functions */
/* 0x0001 is reserved for enable everything */
#define SYSRQ_ENABLE_LOG 0x0002
#define SYSRQ_ENABLE_KEYBOARD 0x0004
#define SYSRQ_ENABLE_DUMP 0x0008
#define SYSRQ_ENABLE_SYNC 0x0010
#define SYSRQ_ENABLE_REMOUNT 0x0020
#define SYSRQ_ENABLE_SIGNAL 0x0040
#define SYSRQ_ENABLE_BOOT 0x0080
#define SYSRQ_ENABLE_RTNICE 0x0100
struct sysrq_key_op {
void (*handler)(int);
char *help_msg;
char *action_msg;
int enable_mask;
};
#ifdef CONFIG_MAGIC_SYSRQ
/* Generic SysRq interface -- you may call it from any device driver, supplying
* ASCII code of the key, pointer to registers and kbd/tty structs (if they
* are available -- else NULL's).
*/
void handle_sysrq(int key);
void __handle_sysrq(int key, bool check_mask);
int register_sysrq_key(int key, struct sysrq_key_op *op);
int unregister_sysrq_key(int key, struct sysrq_key_op *op);
struct sysrq_key_op *__sysrq_get_key_op(int key);
int sysrq_toggle_support(int enable_mask);
int sysrq_mask(void);
#else
static inline void handle_sysrq(int key)
{
}
static inline void __handle_sysrq(int key, bool check_mask)
{
}
static inline int register_sysrq_key(int key, struct sysrq_key_op *op)
{
return -EINVAL;
}
static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op)
{
return -EINVAL;
}
static inline int sysrq_mask(void)
{
/* Magic SysRq disabled mask */
return 0;
}
#endif
#endif /* _LINUX_SYSRQ_H */