linux/drivers/input
Bryam Vargas 39b12daf1a Input: mms114 - reject an oversized device packet size
[ Upstream commit 66725039f7 ]

mms114_interrupt() reads a packet of touch data from the device into a
fixed-size on-stack buffer

	struct mms114_touch touch[MMS114_MAX_TOUCH];

which holds MMS114_MAX_TOUCH (10) events of MMS114_EVENT_SIZE (8) bytes,
i.e. 80 bytes. The length of the I2C read into it is taken verbatim from
the device:

	packet_size = mms114_read_reg(data, MMS114_PACKET_SIZE);
	if (packet_size <= 0)
		goto out;
	...
	error = __mms114_read_reg(data, MMS114_INFORMATION, packet_size,
			(u8 *)touch);

packet_size is a single device register byte (0x0F) and the only check
is the lower bound packet_size <= 0; it is never bounded against the
size of touch[]. A malfunctioning, malicious or counterfeit controller
(or an attacker tampering with the I2C bus) can report a packet_size of
up to 255, so __mms114_read_reg() writes up to 175 bytes past the end of
touch[] on the IRQ-thread stack: a stack out-of-bounds write that can
overwrite the stack canary, saved registers and the return address.

A well-formed device never reports more than the buffer holds, so reject
an oversized packet and drop the report, consistent with the handler's
other error paths, rather than reading past the buffer.

Fixes: 07b8481d4a ("Input: add MELFAS mms114 touchscreen driver")
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260612-b4-disp-dc4b8dc4-v1-1-d7cb0a828d92@proton.me
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
[ changed `&client->dev` to `&data->client->dev` since 6.1's interrupt handler lacks the `client` local variable ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-08-23 14:17:18 +02:00
..
gameport bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
joystick Input: iforce - validate input packet lengths 2026-08-23 14:17:15 +02:00
keyboard Input: atkbd - skip deactivate for Xiaomi Book Pro 14's internal keyboard 2026-08-23 14:17:15 +02:00
misc Input: ims-pcu - fix logic error in packet reset 2026-08-19 17:13:52 +02:00
mouse Input: focaltech - fix array out-of-bounds in focaltech_process_rel_packet 2026-08-23 14:17:15 +02:00
rmi4 Input: synaptics-rmi4 - propagate F54 worker errors to V4L2 queue 2026-08-23 14:17:16 +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 - reject an oversized device packet size 2026-08-23 14:17:18 +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 - fix information leak in evdev_pass_values() 2026-08-19 17:14:15 +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