Input - keyboard: fix theoretical race on vt switch
Subsystems (2)
PATCH 1/1 Input - keyboard: fix theoretical race on vt switch
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.
--- drivers/char/keyboard.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/keyboard.c +1 -1
@@ -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 ;
Signature · 1 line
1.6.3.2
Quoted 18 lines · Alan Jenkins
Switching virtual consoles could change
fg_consolebetweenvc = vc_cons[fg_console].d
and
kbd =kbd_table+fg_consoleReplace the second instance of
fg_consolewithvc->vc_num.Signed-off-by Alan Jenkins <[email protected]>--- drivers/char/keyboard.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/char/keyboard.c +0
-0
drivers/char/keyboard.c static void kbd_keycode(unsigned int keycode, int down, int hw_raw) · line 1160
Quoted 5 lines
drivers/char/keyboard.c +1
-1@@ -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...
Signature · 1 line
Dmitry
PATCH v2 1/1 Input - keyboard: fix theoretical race on vt switch
Quoted 10 lines · Dmitry Torokhov
Review
Quoted 5 lines · Alan Jenkins
(quoted diff) +1
-1- kbd = kbd_table + fg_console; + kbd = kbd_table + vc->vc_num;Hmm, I see more such cases there...
Oops, sorry. I think there's only one more case, it's just embarrassingly close to the other one.
Regards
Alan
---
Quoted 1 line
From
e02f5d1cd72bc0344654872278f7f8313bc9325eMon Sep 17 00:00:00 2001
From: Alan Jenkins <[email protected]>
Date: Sun, 30 Aug 2009 17:40:40 +0100
Subject: [PATCHv2] Input - keyboard: close race on vt-switch
A VT switch can theoretically change fg_console between
vc = vc_cons[fg_console].d
and
kbd = kbd_table + fg_console
Fix it by replacing the second fg_console with vc->vc_num.
--- drivers/char/keyboard.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/keyboard.c +2 -2
@@ -1136,7 +1136,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char ustatic void kbd_rawcode (unsigned char data) {struct vc_data *vc = vc_cons[fg_console].d; - kbd = kbd_table + fg_console; + kbd = kbd_table + vc->vc_num;if (kbd->kbdmode ==VC_RAW )put_queue (vc, data); }
@@ -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 ;
Signature · 1 line
1.5.4.3