Commit 7ab7b5ad authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: sysrq - rework re-inject logic

Internally 'disable' the filter when re-injecting Alt-SysRq instead
of relying on input core to suppress delivery of injected events
to the originating handler.

This allows to revert commit 5fdbe44d
which causes problems with existing userspace programs trying to
loopback the events via evdev.
Reported-by: default avatarKristen Carlson Accardi <kristen@linux.intel.com>
Cc: stable@kernel.org
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 19e95541
...@@ -571,6 +571,7 @@ struct sysrq_state { ...@@ -571,6 +571,7 @@ struct sysrq_state {
unsigned int alt_use; unsigned int alt_use;
bool active; bool active;
bool need_reinject; bool need_reinject;
bool reinjecting;
}; };
static void sysrq_reinject_alt_sysrq(struct work_struct *work) static void sysrq_reinject_alt_sysrq(struct work_struct *work)
...@@ -581,6 +582,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work) ...@@ -581,6 +582,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
unsigned int alt_code = sysrq->alt_use; unsigned int alt_code = sysrq->alt_use;
if (sysrq->need_reinject) { if (sysrq->need_reinject) {
/* we do not want the assignment to be reordered */
sysrq->reinjecting = true;
mb();
/* 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, KEY_SYSRQ, 1);
...@@ -589,6 +594,9 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work) ...@@ -589,6 +594,9 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0); input_inject_event(handle, EV_KEY, KEY_SYSRQ, 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);
mb();
sysrq->reinjecting = false;
} }
} }
...@@ -599,6 +607,13 @@ static bool sysrq_filter(struct input_handle *handle, ...@@ -599,6 +607,13 @@ static bool sysrq_filter(struct input_handle *handle,
bool was_active = sysrq->active; bool was_active = sysrq->active;
bool suppress; bool suppress;
/*
* Do not filter anything if we are in the process of re-injecting
* Alt+SysRq combination.
*/
if (sysrq->reinjecting)
return false;
switch (type) { switch (type) {
case EV_SYN: case EV_SYN:
...@@ -629,7 +644,7 @@ static bool sysrq_filter(struct input_handle *handle, ...@@ -629,7 +644,7 @@ static bool sysrq_filter(struct input_handle *handle,
sysrq->alt_use = sysrq->alt; sysrq->alt_use = sysrq->alt;
/* /*
* If nothing else will be pressed we'll need * If nothing else will be pressed we'll need
* to * re-inject Alt-SysRq keysroke. * to re-inject Alt-SysRq keysroke.
*/ */
sysrq->need_reinject = true; sysrq->need_reinject = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment