diff mbox

Input - keyboard: fix theoretical race on vt switch

Message ID 4A9FE929.8030804@tuffmail.co.uk
State New, archived
Headers show

Commit Message

Alan Jenkins Sept. 3, 2009, 4:04 p.m. UTC
Switching virtual consoles could change fg_console between

	vc = vc_cons[fg_console].d
and
	kbd = kbd_table + fg_console

Replace the second instance of fg_console with vc->vc_num.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
---
 drivers/char/keyboard.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Dmitry Torokhov Sept. 5, 2009, 7:09 a.m. UTC | #1
On Thu, Sep 03, 2009 at 05:04:57PM +0100, Alan Jenkins wrote:
> Switching virtual consoles could change fg_console between
> 
> 	vc = vc_cons[fg_console].d
> and
> 	kbd = kbd_table + fg_console
> 
> Replace the second instance of fg_console with vc->vc_num.
> 
> Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
> ---
>  drivers/char/keyboard.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
> index 737be95..4b564c5 100644
> --- a/drivers/char/keyboard.c
> +++ b/drivers/char/keyboard.c
> @@ -1157,7 +1157,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
>  		tty->driver_data = vc;
>  	}
>  
> -	kbd = kbd_table + fg_console;
> +	kbd = kbd_table + vc->vc_num;

Hmm, I see more such cases there...
diff mbox

Patch

diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 737be95..4b564c5 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1157,7 +1157,7 @@  static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 		tty->driver_data = vc;
 	}
 
-	kbd = kbd_table + fg_console;
+	kbd = kbd_table + vc->vc_num;
 
 	if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
 		sysrq_alt = down ? keycode : 0;