HID: hid-input: clear unmapped usages
PATCH v2 1/1 HID: hid-input: clear unmapped usages
We should not be leaving half-mapped usages with potentially invalid keycodes, as that may confuse hidinput_find_key() when the key is located by index, which may end up feeding way too large keycode into the VT keyboard handler and cause OOB write there:
BUG: KASAN: global-out-of-bounds in clear_bit include/asm-generic/bitops-instrumented.h:56 [inline] BUG: KASAN: global-out-of-bounds in kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] BUG: KASAN: global-out-of-bounds in kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 Write of size 8 at addr ffffffff89a1b2d8 by task syz-executor108/1722 ... kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 input_to_handler+0x3b6/0x4c0 drivers/input/input.c:118 input_pass_values.part.0+0x2e3/0x720 drivers/input/input.c:145 input_pass_values drivers/input/input.c:949 [inline] input_set_keycode+0x290/0x320 drivers/input/input.c:954 evdev_handle_set_keycode_v2+0xc4/0x120 drivers/input/evdev.c:882 evdev_do_ioctl drivers/input/evdev.c:1150 [inline]
---
v2: fixed up interaction with hid-multitouch according to Benjamin's feedback
Please consider tagging for stable.
drivers/hid/hid-input.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/hid/hid-input.c +12 -4
@@ -1132,9 +1132,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel } mapped: -if (device->driver->input_mapped && device->driver->input_mapped (device, - hidinput, field, usage, &bit, &max) <0 ) - goto ignore; +if (device->driver->input_mapped && + device->driver->input_mapped (device, hidinput, field, usage, + &bit, &max) <0 ) { +/* +* The driver indicated that no further generic handling +* of the usage is desired. +*/ +return ; + }set_bit (usage->type, input->evbit);
@@ -1215,9 +1221,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielset_bit (MSC_SCAN , input->mscbit); } -ignore:return ; +ignore: + usage->type =0 ; + usage->code =0 ; } static void hidinput_handle_scroll(struct hid_usage *usage,
Signature · 5 lines
2.24.0.393.g34dc348eaf-goog -- Dmitry
Jiri Kosina
maintainerQuoted 19 lines · Dmitry Torokhov
We should not be leaving half-mapped usages with potentially invalid keycodes, as that may confuse
hidinput_find_key()when the key is located by index, which may end up feeding way too large keycode into the VT keyboard handler and cause OOB write there:BUG: KASAN: global-out-of-bounds in clear_bit include/asm-generic/bitops-instrumented.h:56 [inline] BUG: KASAN: global-out-of-bounds in kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] BUG: KASAN: global-out-of-bounds in kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 Write of size 8 at addr ffffffff89a1b2d8 by task syz-executor108/1722 ... kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 input_to_handler+0x3b6/0x4c0 drivers/input/input.c:118 input_pass_values.part.0+0x2e3/0x720 drivers/input/input.c:145 input_pass_values drivers/input/input.c:949 [inline] input_set_keycode+0x290/0x320 drivers/input/input.c:954 evdev_handle_set_keycode_v2+0xc4/0x120 drivers/input/evdev.c:882 evdev_do_ioctl drivers/input/evdev.c:1150 [inline]
Quoted 8 lines
Reported-by [email protected]Signed-off-by Dmitry Torokhov <[email protected]>---
v2: fixed up interaction with hid-multitouch according to Benjamin's feedback
Please consider tagging for stable.
I'd like to push this for 5.5 (and tag for stable), but would prefer this to have gone through the full battery of Benjamin's testing infrastructure first.
Benjamin, did you have chance to run Dmitry's patch through your machinery?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Benjamin Tissoires
Tested-byHi,
Quoted 29 lines · Jiri Kosina
Quoted 26 lines · Dmitry Torokhov
We should not be leaving half-mapped usages with potentially invalid keycodes, as that may confuse
hidinput_find_key()when the key is located by index, which may end up feeding way too large keycode into the VT keyboard handler and cause OOB write there:BUG: KASAN: global-out-of-bounds in clear_bit include/asm-generic/bitops-instrumented.h:56 [inline] BUG: KASAN: global-out-of-bounds in kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] BUG: KASAN: global-out-of-bounds in kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 Write of size 8 at addr ffffffff89a1b2d8 by task syz-executor108/1722 ... kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 input_to_handler+0x3b6/0x4c0 drivers/input/input.c:118 input_pass_values.part.0+0x2e3/0x720 drivers/input/input.c:145 input_pass_values drivers/input/input.c:949 [inline] input_set_keycode+0x290/0x320 drivers/input/input.c:954 evdev_handle_set_keycode_v2+0xc4/0x120 drivers/input/evdev.c:882 evdev_do_ioctl drivers/input/evdev.c:1150 [inline]Reported-by [email protected]Signed-off-by Dmitry Torokhov <[email protected]>---
v2: fixed up interaction with hid-multitouch according to Benjamin's feedback
Quoted 8 lines
Quoted 1 line
Please consider tagging for stable.
I'd like to push this for 5.5 (and tag for stable), but would prefer this to have gone through the full battery of Benjamin's testing infrastructure first.
Benjamin, did you have chance to run Dmitry's patch through your machinery?
yep, this one was OK, so:
Cheers,
Benjamin
Quoted 7 lines
Thanks,
--
Jiri Kosina
SUSE Labs
Jiri Kosina
maintainerQuoted 32 lines · Benjamin Tissoires
Quoted 32 lines
Quoted 19 lines
We should not be leaving half-mapped usages with potentially invalid keycodes, as that may confuse
hidinput_find_key()when the key is located by index, which may end up feeding way too large keycode into the VT keyboard handler and cause OOB write there:BUG: KASAN: global-out-of-bounds in clear_bit include/asm-generic/bitops-instrumented.h:56 [inline] BUG: KASAN: global-out-of-bounds in kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] BUG: KASAN: global-out-of-bounds in kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 Write of size 8 at addr ffffffff89a1b2d8 by task syz-executor108/1722 ... kbd_keycode drivers/tty/vt/keyboard.c:1411 [inline] kbd_event+0xe6b/0x3790 drivers/tty/vt/keyboard.c:1495 input_to_handler+0x3b6/0x4c0 drivers/input/input.c:118 input_pass_values.part.0+0x2e3/0x720 drivers/input/input.c:145 input_pass_values drivers/input/input.c:949 [inline] input_set_keycode+0x290/0x320 drivers/input/input.c:954 evdev_handle_set_keycode_v2+0xc4/0x120 drivers/input/evdev.c:882 evdev_do_ioctl drivers/input/evdev.c:1150 [inline]Quoted 8 lines
Reported-by [email protected]Signed-off-by Dmitry Torokhov <[email protected]>---
v2: fixed up interaction with hid-multitouch according to Benjamin's feedback
Please consider tagging for stable.
I'd like to push this for 5.5 (and tag for stable), but would prefer this to have gone through the full battery of Benjamin's testing infrastructure first.
Quoted 5 lines
Quoted 2 lines
Benjamin, did you have chance to run Dmitry's patch through your machinery?
yep, this one was OK, so:
Tested-by Benjamin Tissoires <[email protected]>
Thanks, I am queuing this in for-5.5/upstream-fixes.
Signature · 2 lines
Jiri Kosina SUSE Labs