linux/drivers/input
Dmitry Torokhov f27fa9b39f Input: evdev - sanitize event type index when fetching event masks
commit 3abd29c61d upstream.

The user-supplied event type index passed to EVIOCGMASK / EVIOCSMASK
ioctls is used to index the static counts array in evdev_get_mask_cnt()
and client evmasks array in evdev_get_mask().

While the event type is architecturally bounded by EV_CNT, speculative
execution may mispredict bounds checks and perform out-of-bounds loads.

Sanitize the event type index in evdev_get_mask_cnt() branchlessly using
array_index_mask_nospec(). This clamps the index to 0 for safe array
access and forces the returned count to 0 speculatively when the index
is out of bounds.

We do not need additional array_index_nospec() calls in evdev_get_mask()
because evdev_get_mask_cnt() speculatively forces the count (and
resulting xfer_size) to 0 for out-of-bounds types, preventing any
speculative memory access to client evmasks array.

Reported-by: "Wagenaar, C.C.J. (Chris)" <c.c.j.wagenaar@vu.nl>
Cc: stable@vger.kernel.org
Assisted-by: Antigravity:gemini-3.6-flash
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/anFCAfvxwXB5eJF1@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-08-19 17:14:14 +02:00
..
gameport bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
joystick Input: maplecontrol - set driver data before registering input device 2026-07-24 15:51:26 +02:00
keyboard Input: maple_keyb - set driver data before registering input device 2026-07-24 15:51:26 +02:00
misc Input: ims-pcu - fix logic error in packet reset 2026-08-19 17:13:52 +02:00
mouse Input: maplemouse - set driver data before registering input device 2026-07-24 15:51:26 +02:00
rmi4 Input: synaptics-rmi4 - bound the F30 keymap to the GPIO/LED count 2026-07-24 15:51:25 +02:00
serio Input: i8042 - add TUXEDO InfinityBook Max 16 Gen10 AMD to i8042 quirk table 2026-04-18 10:33:32 +02:00
tablet Input: pegasus-notetaker - fix potential out-of-bounds access 2025-12-07 06:09:33 +09:00
touchscreen Input: mms114 - fix multi-touch slot corruption 2026-07-24 15:51:26 +02:00
apm-power.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
evbug.c Input: evbug - remove an empty comment block 2021-05-24 21:06:39 -07:00
evdev.c Input: evdev - sanitize event type index when fetching event masks 2026-08-19 17:14:14 +02:00
ff-core.c Input: ff-core - prefer struct_size over open coded arithmetic 2024-07-18 13:07:28 +02:00
ff-memless.c Input: ff-memless - kill timer in destroy() 2019-11-15 11:45:03 -08:00
input-compat.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
input-compat.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
input-leds.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
input-mt.c Input: MT - limit max slots 2024-09-04 13:23:37 +02:00
input-poller.c Input: use input_device_enabled() 2020-12-02 22:10:33 -08:00
input-poller.h Input: add support for polling to input devices 2019-08-20 12:04:07 -07:00
input.c Input: try trimming too long modalias strings 2024-07-05 09:14:15 +02:00
joydev.c Input: joydev - prevent use of not validated data in JSIOCSBTNMAP ioctl 2021-07-04 23:02:10 -07:00
Kconfig um: allow disabling NO_IOMEM 2021-06-17 21:44:50 +02:00
Makefile Input: touchscreen - move helper functions to core 2021-03-25 11:14:09 -07:00
matrix-keymap.c Input: matrix-keymap - switch to use device_property_count_u32() 2019-08-12 00:03:13 -07:00
mousedev.c *: convert stream-like files -> stream_open, even if they use noop_llseek 2019-07-14 16:09:19 +03:00
sparse-keymap.c Input: Use fallthrough pseudo-keyword 2020-07-07 11:25:54 -07:00
touchscreen.c Input: touchscreen - avoid bitwise vs logical OR warning 2021-10-15 22:22:54 -07:00