sysrq: add ALT+LEFTCTRL to trigger crash dump
Upstream: no Most out of band systems doesn't support sysrq key,so add left ctrl key to trigger crash dump Signed-off-by: katrinzhou <katrinzhou@tencent.com> Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
parent
40521e8d0e
commit
95c98461d1
|
@ -58,6 +58,7 @@
|
||||||
/* Whether we react on sysrq keys or just ignore them */
|
/* Whether we react on sysrq keys or just ignore them */
|
||||||
static int __read_mostly sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
|
static int __read_mostly sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
|
||||||
static bool __read_mostly sysrq_always_enabled;
|
static bool __read_mostly sysrq_always_enabled;
|
||||||
|
static bool __read_mostly sysrq_use_leftctrl = true;
|
||||||
|
|
||||||
static bool sysrq_on(void)
|
static bool sysrq_on(void)
|
||||||
{
|
{
|
||||||
|
@ -796,6 +797,7 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
|
||||||
container_of(work, struct sysrq_state, reinject_work);
|
container_of(work, struct sysrq_state, reinject_work);
|
||||||
struct input_handle *handle = &sysrq->handle;
|
struct input_handle *handle = &sysrq->handle;
|
||||||
unsigned int alt_code = sysrq->alt_use;
|
unsigned int alt_code = sysrq->alt_use;
|
||||||
|
unsigned int sysrq_code = sysrq_use_leftctrl ? KEY_LEFTCTRL : KEY_SYSRQ;
|
||||||
|
|
||||||
if (sysrq->need_reinject) {
|
if (sysrq->need_reinject) {
|
||||||
/* we do not want the assignment to be reordered */
|
/* we do not want the assignment to be reordered */
|
||||||
|
@ -804,10 +806,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
|
||||||
|
|
||||||
/* Simulate press and release of Alt + SysRq */
|
/* Simulate press and release of Alt + SysRq */
|
||||||
input_inject_event(handle, EV_KEY, alt_code, 1);
|
input_inject_event(handle, EV_KEY, alt_code, 1);
|
||||||
input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
|
input_inject_event(handle, EV_KEY, sysrq_code, 1);
|
||||||
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
|
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
|
||||||
|
|
||||||
input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
|
input_inject_event(handle, EV_KEY, sysrq_code, 0);
|
||||||
input_inject_event(handle, EV_KEY, alt_code, 0);
|
input_inject_event(handle, EV_KEY, alt_code, 0);
|
||||||
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
|
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
|
||||||
|
|
||||||
|
@ -849,6 +851,10 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
|
||||||
sysrq->shift_use = sysrq->shift;
|
sysrq->shift_use = sysrq->shift;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KEY_LEFTCTRL:
|
||||||
|
if (!sysrq_use_leftctrl || sysrq->active)
|
||||||
|
break;
|
||||||
|
fallthrough;
|
||||||
case KEY_SYSRQ:
|
case KEY_SYSRQ:
|
||||||
if (value == 1 && sysrq->alt != KEY_RESERVED) {
|
if (value == 1 && sysrq->alt != KEY_RESERVED) {
|
||||||
sysrq->active = true;
|
sysrq->active = true;
|
||||||
|
@ -874,7 +880,6 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
|
||||||
clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
|
clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (sysrq->active && value && value != 2) {
|
if (sysrq->active && value && value != 2) {
|
||||||
unsigned char c = sysrq_xlate[code];
|
unsigned char c = sysrq_xlate[code];
|
||||||
|
@ -1111,6 +1116,12 @@ int sysrq_toggle_support(int enable_mask)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(sysrq_toggle_support);
|
EXPORT_SYMBOL_GPL(sysrq_toggle_support);
|
||||||
|
|
||||||
|
int sysrq_toggle_sysrq_key(int __sysrq_use_leftctrl)
|
||||||
|
{
|
||||||
|
sysrq_use_leftctrl = !!__sysrq_use_leftctrl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p,
|
static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p,
|
||||||
const struct sysrq_key_op *remove_op_p)
|
const struct sysrq_key_op *remove_op_p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,7 @@ int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op);
|
||||||
extern const struct sysrq_key_op *__sysrq_reboot_op;
|
extern const struct sysrq_key_op *__sysrq_reboot_op;
|
||||||
|
|
||||||
int sysrq_toggle_support(int enable_mask);
|
int sysrq_toggle_support(int enable_mask);
|
||||||
|
int sysrq_toggle_sysrq_key(int __sysrq_use_leftctrl);
|
||||||
int sysrq_mask(void);
|
int sysrq_mask(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1004,6 +1004,8 @@ int proc_dou8vec_minmax(struct ctl_table *table, int write,
|
||||||
EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
|
EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
|
||||||
|
|
||||||
#ifdef CONFIG_MAGIC_SYSRQ
|
#ifdef CONFIG_MAGIC_SYSRQ
|
||||||
|
static int __sysrq_use_leftctrl = 1;
|
||||||
|
|
||||||
static int sysrq_sysctl_handler(struct ctl_table *table, int write,
|
static int sysrq_sysctl_handler(struct ctl_table *table, int write,
|
||||||
void *buffer, size_t *lenp, loff_t *ppos)
|
void *buffer, size_t *lenp, loff_t *ppos)
|
||||||
{
|
{
|
||||||
|
@ -1021,6 +1023,22 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sysrq_use_leftctrl_sysctl_handler(struct ctl_table *table, int write,
|
||||||
|
void __user *buffer, size_t *lenp,
|
||||||
|
loff_t *ppos)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = proc_dointvec(table, write, buffer, lenp, ppos);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (write)
|
||||||
|
sysrq_toggle_sysrq_key(__sysrq_use_leftctrl);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
|
static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
|
||||||
|
@ -1765,6 +1783,14 @@ static struct ctl_table kern_table[] = {
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = sysrq_sysctl_handler,
|
.proc_handler = sysrq_sysctl_handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.procname = "sysrq_use_leftctrl",
|
||||||
|
.data = &__sysrq_use_leftctrl,
|
||||||
|
.maxlen = sizeof(int),
|
||||||
|
.mode = 0644,
|
||||||
|
.proc_handler = sysrq_use_leftctrl_sysctl_handler,
|
||||||
|
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PROC_SYSCTL
|
#ifdef CONFIG_PROC_SYSCTL
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue