Re: [PATCH] Add KD_X console mode to avoid keyboard passthrough

From: Dmitry Torokhov
Date: Mon Oct 13 2008 - 23:13:00 EST


Hi Matthew,

On Sun, Oct 12, 2008 at 06:47:10PM +0100, Matthew Garrett wrote:
> When using the evdev input driver, X currently claims the devices
> exclusively in order to prevent characters leaking through to the
> underlying VT. This has the downside that other consumers of input
> events no longer receive the keys - rfkill and mouseemu no longer work
> in the kernel, and hal is unable to pass through input events. Removing
> the exclusive access results in events being passed through to the
> underlying VT, which may result in leaking sensitive information.
>
> This patch adds an extra KD_X mode. It's semantically identical to
> KD_GRAPHICS, except that keyboard events are no longer sent to the
> console device. This allows X to avoid exclusive access without breaking
> any applications which depend upon the existing KD_GRAPHICS semantics.
>

Is this really needed? The current X does not leak anything onto its VT
and the new one should not have either, unless they forget to switch
virtual console into raw mode. Plus, if you make everything work with
KD_GRAPHICS you don't have to have new kernel.

>
> diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
> index 7b3a212..b0b8285 100644
> --- a/drivers/char/keyboard.c
> +++ b/drivers/char/keyboard.c
> @@ -1298,6 +1298,10 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
> static void kbd_event(struct input_handle *handle, unsigned int event_type,
> unsigned int event_code, int value)
> {
> + struct vc_data *vc = vc_cons[fg_console].d;
> +
> + if (vc->vc_mode == KD_X)
> + return;

This surely kills SysRq handling.

> if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev))
> kbd_rawcode(value);
> if (event_type == EV_KEY)
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/