Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2)
@ 2026-11-27 20:09 Lee Jones
  2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, Pierre-Loup A. Griffais,
	Uwe Kleine-König (The Capable Hub), Adam Buchbinder,
	Alexandre Torgue, Andi Shyti, Anthony Liguori, Christoph Fritz,
	Dan Murphy, David Heidelberg, Dmitry Torokhov, Dominic Cerquetti,
	Elliot Tester, Franz Lehner, Greg Kroah-Hartman,
	Griffin Kroah-Hartman, Hans de Goede, Ivan Hawkes, Jan Kratochvil,
	Javier Martinez Canillas, Jeff LaBundy, Jens Reidel,
	Juergen Gross, linux-arm-kernel, linux-input, linux-stm32,
	Marko Friedemann, Markus Armbruster, Maxime Coquelin,
	Neil Armstrong, Oleksandr Andrushchenko, Oliver Schwartz,
	Pavel Rojtberg, Rob Herring, Steven Toth, Vojtech Pavlik

These issues were reported by Sashiko.

This is batch 2 of Input bug fixes, based on input/next.  It addresses
out-of-bounds accesses and underflows in adi, probe and unbind work
UAFs in xpad and aw86927, sysfs information disclosure in stmfts,
NULL dereferences in xen-kbdfront and goodix_berlin, SPI transfer size
underflow in goodix_berlin_spi, and suspend work stopping in drv2665
and drv2667.

Cc: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Andi Shyti <andi@etezian.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Christoph Fritz <chf.fritz@googlemail.com>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: David Heidelberg <david@ixit.cz>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Dominic Cerquetti <binary1230@yahoo.com>
Cc: Elliot Tester <elliotctester@gmail.com>
Cc: Franz Lehner <franz@caos.at>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
Cc: Hans de Goede <hansg@kernel.org>
Cc: Ivan Hawkes <blackhawk@ivanhawkes.com>
Cc: Jan Kratochvil <honza@jikos.cz>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Jeff LaBundy <jeff@labundy.com>
Cc: Jens Reidel <adrian@mainlining.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-input@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: Marko Friedemann <mfr@bmx-chemnitz.de>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Cc: Oliver Schwartz <Oliver.Schwartz@gmx.de>
Cc: Pavel Rojtberg <rojtberg@gmail.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Steven Toth <steve@toth.demon.co.uk>
Cc: Vojtech Pavlik <vojtech@ucw.cz>

Lee Jones (10):
  Input: adi - prevent off-by-one write in adi_read_packet()
  Input: adi - validate axis and button counts in adi_id_decode()
  Input: xpad - cancel presence work on xpad360w_start_input() failure
  Input: aw86927 - use devm_work_autocancel() for haptics play work
  Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status
    sysfs
  Input: xen-kbdfront - check info->ptr and info->kbd before
    dereferencing
  Input: drv2665 - disable haptics work across suspend and resume
  Input: drv2667 - disable haptics work across suspend and resume
  Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL
  Input: goodix_berlin_spi - validate ic_data and SPI max transfer size

 drivers/input/joystick/adi.c                  | 45 ++++++++++++++++++-
 drivers/input/joystick/xpad.c                 |  6 ++-
 drivers/input/misc/aw86927.c                  |  6 ++-
 drivers/input/misc/drv2665.c                  | 15 ++++---
 drivers/input/misc/drv2667.c                  | 15 ++++---
 drivers/input/misc/xen-kbdfront.c             |  7 +--
 drivers/input/touchscreen/goodix_berlin_i2c.c |  3 ++
 drivers/input/touchscreen/goodix_berlin_spi.c |  6 +++
 drivers/input/touchscreen/stmfts.c            |  5 ++-
 9 files changed, 88 insertions(+), 20 deletions(-)

-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet()
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
@ 2026-11-27 20:09 ` Lee Jones
  2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Vojtech Pavlik, linux-input, linux-kernel; +Cc: stable

adi[i].data holds ADI_MAX_LENGTH bytes and adi[i].ret is initialised to
-1 and pre-incremented before indexing adi[i].data[++adi[i].ret].
Checking adi[i].ret < ADI_MAX_LENGTH therefore allows a write to
adi[i].data[ADI_MAX_LENGTH] when adi[i].ret is ADI_MAX_LENGTH - 1,
corrupting the adjacent field in struct adi_port.

Compare adi[i].ret against ADI_MAX_LENGTH - 1 so the pre-incremented
index always stays within bounds.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Closes: https://sashiko.dev/#/bug/linux-951334ec-a996-4dc4-a03b-d7e6f716e5de
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/joystick/adi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index e07b71978509..cfd585f89c2c 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -141,10 +141,14 @@ static void adi_read_packet(struct adi_port *port)
 		for (i = 0; i < 2; i++, w >>= 2, x >>= 2) {
 			t[i]--;
 			if ((w & 0x30) && s[i]) {
-				if ((w & 0x30) < 0x30 && adi[i].ret < ADI_MAX_LENGTH && t[i] > 0) {
+				if ((w & 0x30) < 0x30 &&
+				    adi[i].ret < ADI_MAX_LENGTH - 1 &&
+				    t[i] > 0) {
 					adi[i].data[++adi[i].ret] = w;
 					t[i] = gameport_time(gameport, ADI_MAX_STROBE);
-				} else t[i] = 0;
+				} else {
+					t[i] = 0;
+				}
 			} else if (!(x & 0x30)) s[i] = 1;
 		}
 	} while (t[0] > 0 || t[1] > 0);
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode()
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
  2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
@ 2026-11-27 20:09 ` Lee Jones
  2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Vojtech Pavlik, linux-input, linux-kernel; +Cc: stable

adi_id_decode() decodes axis, hat, and button counts from the device ID
packet without checking for underflow when computing 10-bit axes or
subtracting 4 pad buttons on ThunderPad Digital and WingMan GamePad
devices, and without checking that the total axis and button counts fit
within the static adi_abs and adi_key tables.  Malformed ID packets can
therefore underflow these fields and cause out-of-bounds reads from
adi->abs and adi->key in adi_init_input(), adi_init_center(), and
adi_read().

Reject packets that would underflow axes10 or buttons, and verify that
the decoded axis and button counts fit within the corresponding
adi_abs and adi_key table sizes.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Closes: https://sashiko.dev/#/bug/linux-92046c21-e0a8-4274-a502-20ca723131b1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/joystick/adi.c | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index cfd585f89c2c..1db1dfa0ae14 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -70,9 +70,27 @@ static short adi_cm2_key[] =	{ BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7,
 static char* adi_abs[] = { adi_wmi_abs, adi_wmgpe_abs, adi_wmf_abs, adi_cm2_abs, adi_wmi_abs, adi_wmf_abs,
 			   adi_wmgpe_abs, adi_wmed3d_abs, adi_wmgpe_abs, adi_wmgpe_abs, adi_wmi_abs };
 
+static const int adi_abs_len[] = {
+	ARRAY_SIZE(adi_wmi_abs), ARRAY_SIZE(adi_wmgpe_abs),
+	ARRAY_SIZE(adi_wmf_abs), ARRAY_SIZE(adi_cm2_abs),
+	ARRAY_SIZE(adi_wmi_abs), ARRAY_SIZE(adi_wmf_abs),
+	ARRAY_SIZE(adi_wmgpe_abs), ARRAY_SIZE(adi_wmed3d_abs),
+	ARRAY_SIZE(adi_wmgpe_abs), ARRAY_SIZE(adi_wmgpe_abs),
+	ARRAY_SIZE(adi_wmi_abs)
+};
+
 static short* adi_key[] = { adi_wmi_key, adi_wmgpe_key, adi_cm2_key, adi_cm2_key, adi_wmi_key, adi_cm2_key,
 			    adi_wmgpe_key, adi_wmed3d_key, adi_wmgpe_key, adi_wmgpe_key, adi_wmi_key };
 
+static const int adi_key_len[] = {
+	ARRAY_SIZE(adi_wmi_key), ARRAY_SIZE(adi_wmgpe_key),
+	ARRAY_SIZE(adi_cm2_key), ARRAY_SIZE(adi_cm2_key),
+	ARRAY_SIZE(adi_wmi_key), ARRAY_SIZE(adi_cm2_key),
+	ARRAY_SIZE(adi_wmgpe_key), ARRAY_SIZE(adi_wmed3d_key),
+	ARRAY_SIZE(adi_wmgpe_key), ARRAY_SIZE(adi_wmgpe_key),
+	ARRAY_SIZE(adi_wmi_key)
+};
+
 /*
  * Hat to axis conversion arrays.
  */
@@ -351,6 +369,10 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
 	i = adi_get_bits(adi, 4);
 
 	if (t & ADI_FLAG_10BIT) {
+		if (i > adi->axes8) {
+			adi->length = 0;
+			return;
+		}
 		adi->axes10 = adi->axes8 - i;
 		adi->axes8 = i;
 	}
@@ -370,10 +392,18 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
 
 	switch (adi->id) {
 		case ADI_ID_TPD:
+			if (adi->buttons < 4) {
+				adi->length = 0;
+				return;
+			}
 			adi->pad = 4;
 			adi->buttons -= 4;
 			break;
 		case ADI_ID_WGP:
+			if (adi->buttons < 4) {
+				adi->length = 0;
+				return;
+			}
 			adi->pad = 0;
 			adi->buttons -= 4;
 			break;
@@ -381,6 +411,13 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
 			adi->pad = -1;
 			break;
 	}
+
+	t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
+	if (adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2 >
+	    adi_abs_len[t] || adi->buttons > adi_key_len[t]) {
+		adi->length = 0;
+		return;
+	}
 }
 
 static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
  2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
  2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
@ 2026-11-27 20:09 ` Lee Jones
  2026-11-27 20:24   ` sashiko-bot
  2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Elliot Tester, Marko Friedemann,
	Oliver Schwartz, Steven Toth, Franz Lehner, Ivan Hawkes,
	Dominic Cerquetti, Adam Buchbinder, Jan Kratochvil,
	Christoph Fritz, Pavel Rojtberg, Pierre-Loup A. Griffais,
	Greg Kroah-Hartman, linux-input, linux-kernel
  Cc: stable

xpad360w_start_input() submits xpad->irq_in before sending the presence
inquiry.  If an incoming packet schedules xpad->work before
xpad_inquiry_pad_presence() fails, the error path kills the URB without
cancelling xpad->work, allowing xpad_presence_work() to run after
xpad_probe() frees xpad or leaving any input device registered by the
worker torn down improperly.

Cancel xpad->work synchronously after killing xpad->irq_in on error, and
run xpad_deinit_input() and xpad_stop_output() on probe failure in case
xpad_presence_work() already completed before cancellation.

Fixes: 09c8b00ae3e1 ("Input: xpad - handle "present" and "gone" correctly")
Closes: https://sashiko.dev/#/bug/linux-0c0def42-a340-45bb-860d-c99ba757f43b
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/joystick/xpad.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 86f4e756a7fc..ba0f5684f3d6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1880,6 +1880,7 @@ static int xpad360w_start_input(struct usb_xpad *xpad)
 	error = xpad_inquiry_pad_presence(xpad);
 	if (error) {
 		usb_kill_urb(xpad->irq_in);
+		cancel_work_sync(&xpad->work);
 		return error;
 	}
 
@@ -2210,8 +2211,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 		 * we're waiting for.
 		 */
 		error = xpad360w_start_input(xpad);
-		if (error)
+		if (error) {
+			xpad_deinit_input(xpad);
+			xpad_stop_output(xpad);
 			goto err_deinit_output;
+		}
 		/*
 		 * Wireless controllers require RESET_RESUME to work properly
 		 * after suspend. Ideally this quirk should be in usb core
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (2 preceding siblings ...)
  2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
@ 2026-11-27 20:09 ` Lee Jones
  2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Griffin Kroah-Hartman, linux-input,
	linux-kernel
  Cc: stable

aw86927_probe() initialises haptics->play_work with INIT_WORK() and
relies solely on aw86927_close() to cancel it.  When the input device is
inhibited at unbind time, input_unregister_device() skips
aw86927_close() while evdev flush can still schedule play_work, allowing
aw86927_haptics_play_work() to run after devres frees haptics.

Use devm_work_autocancel() before registering the input device so devres
cancels play_work after input_unregister_device() and before freeing
driver resources.

Fixes: 52e06d564ce6 ("Input: aw86927 - add driver for Awinic AW86927")
Closes: https://sashiko.dev/#/bug/linux-819bee30-4290-430a-b9a3-7dbb99d73505
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/aw86927.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 0657c52b4c79..2d6bfb57afe1 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -10,6 +10,7 @@
 #include <linux/bitfield.h>
 #include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/devm-helpers.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
@@ -826,7 +827,10 @@ static int aw86927_probe(struct i2c_client *client)
 	if (err)
 		return dev_err_probe(haptics->dev, err, "Failed to request threaded irq\n");
 
-	INIT_WORK(&haptics->play_work, aw86927_haptics_play_work);
+	err = devm_work_autocancel(haptics->dev, &haptics->play_work,
+				   aw86927_haptics_play_work);
+	if (err)
+		return err;
 
 	haptics->input_dev->name = "aw86927-haptics";
 	haptics->input_dev->close = aw86927_close;
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (3 preceding siblings ...)
  2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
@ 2026-11-27 20:09 ` Lee Jones
  2026-11-27 20:35   ` David Heidelberg
  2026-11-27 20:10 ` [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing Lee Jones
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:09 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue,
	David Heidelberg, Andi Shyti, Rob Herring,
	Javier Martinez Canillas, linux-input, linux-stm32,
	linux-arm-kernel, linux-kernel
  Cc: stable

i2c_smbus_read_i2c_block_data() returns the positive byte count on
success or a negative error code on failure.  stmfts_sysfs_read_status()
checks if (err) and returns err directly, so a normal 4-byte read
returns 4 without formatting buf (exposing unpopulated sysfs buffer
bytes), while a 0-byte read formats uninitialised stack memory.

Return negative errors immediately and require sizeof(status) bytes to
be read, matching stmfts_read_system_info().

Fixes: 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")
Closes: https://sashiko.dev/#/bug/linux-bd87edf0-6f79-4318-8780-d69205787e7d
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/touchscreen/stmfts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index 2054c2254947..aada03f96940 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -699,9 +699,12 @@ static ssize_t stmfts_sysfs_read_status(struct device *dev,
 
 	err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_STATUS,
 					    sizeof(status), status);
-	if (err)
+	if (err < 0)
 		return err;
 
+	if (err != sizeof(status))
+		return -EIO;
+
 	return sysfs_emit(buf, "%#02x\n", status[0]);
 }
 
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (4 preceding siblings ...)
  2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
@ 2026-11-27 20:10 ` Lee Jones
  2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:10 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Anthony Liguori, Markus Armbruster,
	Juergen Gross, Oleksandr Andrushchenko, linux-input, linux-kernel
  Cc: stable

When XenStore disables either the pointer or keyboard device,
xenkbd_probe() leaves info->ptr or info->kbd as NULL.
xenkbd_handle_key_event() dereferences info->ptr->keybit and
info->kbd->keybit before checking whether those pointers are valid,
causing a NULL pointer dereference in interrupt context on key events.

Check info->ptr and info->kbd before testing their keybit masks and
remove the unreachable NULL check below.

Fixes: 3ef8a2eeb6dc ("Input: xen-kbdfront - allow better run-time configuration")
Closes: https://sashiko.dev/#/bug/linux-9e0f9c2c-45ab-4045-80b4-47629154e917
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/xen-kbdfront.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 6471d836f6fe..4e0bd4480f83 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -92,9 +92,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
 	struct input_dev *dev;
 	int value = key->pressed;
 
-	if (test_bit(key->keycode, info->ptr->keybit)) {
+	if (info->ptr && test_bit(key->keycode, info->ptr->keybit)) {
 		dev = info->ptr;
-	} else if (test_bit(key->keycode, info->kbd->keybit)) {
+	} else if (info->kbd && test_bit(key->keycode, info->kbd->keybit)) {
 		dev = info->kbd;
 		if (key->pressed && test_bit(key->keycode, info->kbd->key))
 			value = 2; /* Mark as autorepeat */
@@ -103,9 +103,6 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
 		return;
 	}
 
-	if (unlikely(!dev))
-		return;
-
 	input_event(dev, EV_KEY, key->keycode, value);
 	input_sync(dev);
 }
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (5 preceding siblings ...)
  2026-11-27 20:10 ` [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing Lee Jones
@ 2026-11-27 20:10 ` Lee Jones
  2026-11-27 20:10 ` [PATCH 08/10] Input: drv2667 " Lee Jones
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:10 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Uwe Kleine-König (The Capable Hub),
	Dan Murphy, linux-input, linux-kernel
  Cc: stable

drv2665_suspend() puts the device into standby and disables its
regulator without stopping haptics->work.  A pending or timer-scheduled
haptics worker can therefore execute I2C regmap transactions while the
chip is unpowered or the I2C bus is suspended, including when the input
device is inhibited.

Call disable_work_sync() unconditionally in drv2665_suspend() before
entering standby (re-enabling on suspend error) and call enable_work()
unconditionally in drv2665_resume() so the disable count always remains
balanced across suspend/resume cycles.

Fixes: 4d10da13467e ("Input: add TI drv2665 haptics driver")
Closes: https://sashiko.dev/#/bug/linux-c1b30f7c-1836-440f-8a6a-75ada49be7d5
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/drv2665.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/drv2665.c b/drivers/input/misc/drv2665.c
index 90407f8797c7..3ade96308192 100644
--- a/drivers/input/misc/drv2665.c
+++ b/drivers/input/misc/drv2665.c
@@ -228,12 +228,15 @@ static int drv2665_suspend(struct device *dev)
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
+	disable_work_sync(&haptics->work);
+
 	if (input_device_enabled(haptics->input_dev)) {
 		error = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
 					   DRV2665_STANDBY, DRV2665_STANDBY);
 		if (error) {
 			dev_err(dev, "Failed to set standby mode\n");
 			regulator_disable(haptics->regulator);
+			enable_work(&haptics->work);
 			return error;
 		}
 
@@ -243,6 +246,7 @@ static int drv2665_suspend(struct device *dev)
 			regmap_update_bits(haptics->regmap,
 					   DRV2665_CTRL_2,
 					   DRV2665_STANDBY, 0);
+			enable_work(&haptics->work);
 			return error;
 		}
 	}
@@ -253,7 +257,7 @@ static int drv2665_suspend(struct device *dev)
 static int drv2665_resume(struct device *dev)
 {
 	struct drv2665_data *haptics = dev_get_drvdata(dev);
-	int error;
+	int error = 0;
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
@@ -261,7 +265,7 @@ static int drv2665_resume(struct device *dev)
 		error = regulator_enable(haptics->regulator);
 		if (error) {
 			dev_err(dev, "Failed to enable regulator\n");
-			return error;
+			goto out;
 		}
 
 		error = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
@@ -269,12 +273,13 @@ static int drv2665_resume(struct device *dev)
 		if (error) {
 			dev_err(dev, "Failed to unset standby mode\n");
 			regulator_disable(haptics->regulator);
-			return error;
+			goto out;
 		}
-
 	}
 
-	return 0;
+out:
+	enable_work(&haptics->work);
+	return error;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume);
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] Input: drv2667 - disable haptics work across suspend and resume
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (6 preceding siblings ...)
  2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
@ 2026-11-27 20:10 ` Lee Jones
  2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
  2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:10 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Uwe Kleine-König (The Capable Hub),
	Dan Murphy, linux-input, linux-kernel
  Cc: stable

drv2667_suspend() puts the device into standby and disables its
regulator without stopping haptics->work.  A pending or timer-scheduled
haptics worker can therefore execute I2C regmap transactions while the
chip is unpowered or the I2C bus is suspended, including when the input
device is inhibited.

Call disable_work_sync() unconditionally in drv2667_suspend() before
entering standby (re-enabling on suspend error) and call enable_work()
unconditionally in drv2667_resume() so the disable count always remains
balanced across suspend/resume cycles.

Fixes: 1c24622572d6 ("Input: add support for the DRV2667 haptic driver")
Closes: https://sashiko.dev/#/bug/linux-b8ddefd2-393d-487e-8c76-2dbc5ef46b64
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/drv2667.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/drv2667.c b/drivers/input/misc/drv2667.c
index 18cf689d7ef7..3326aeb9874e 100644
--- a/drivers/input/misc/drv2667.c
+++ b/drivers/input/misc/drv2667.c
@@ -405,12 +405,15 @@ static int drv2667_suspend(struct device *dev)
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
+	disable_work_sync(&haptics->work);
+
 	if (input_device_enabled(haptics->input_dev)) {
 		error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
 					   DRV2667_STANDBY, DRV2667_STANDBY);
 		if (error) {
 			dev_err(dev, "Failed to set standby mode\n");
 			regulator_disable(haptics->regulator);
+			enable_work(&haptics->work);
 			return error;
 		}
 
@@ -420,6 +423,7 @@ static int drv2667_suspend(struct device *dev)
 			regmap_update_bits(haptics->regmap,
 					   DRV2667_CTRL_2,
 					   DRV2667_STANDBY, 0);
+			enable_work(&haptics->work);
 			return error;
 		}
 	}
@@ -430,7 +434,7 @@ static int drv2667_suspend(struct device *dev)
 static int drv2667_resume(struct device *dev)
 {
 	struct drv2667_data *haptics = dev_get_drvdata(dev);
-	int error;
+	int error = 0;
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
@@ -438,7 +442,7 @@ static int drv2667_resume(struct device *dev)
 		error = regulator_enable(haptics->regulator);
 		if (error) {
 			dev_err(dev, "Failed to enable regulator\n");
-			return error;
+			goto out;
 		}
 
 		error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
@@ -446,12 +450,13 @@ static int drv2667_resume(struct device *dev)
 		if (error) {
 			dev_err(dev, "Failed to unset standby mode\n");
 			regulator_disable(haptics->regulator);
-			return error;
+			goto out;
 		}
-
 	}
 
-	return 0;
+out:
+	enable_work(&haptics->work);
+	return error;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume);
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (7 preceding siblings ...)
  2026-11-27 20:10 ` [PATCH 08/10] Input: drv2667 " Lee Jones
@ 2026-11-27 20:10 ` Lee Jones
  2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:10 UTC (permalink / raw)
  To: lee, Hans de Goede, Dmitry Torokhov, Neil Armstrong, Jens Reidel,
	linux-input, linux-kernel
  Cc: stable

goodix_berlin_i2c_probe() passes the pointer returned by
i2c_get_match_data() straight to goodix_berlin_probe(), which
unconditionally dereferences ic_data.  If the driver is bound via sysfs
new_device without matching OF or I2C match data, i2c_get_match_data()
returns NULL and causes a NULL pointer dereference.

Return -EINVAL when i2c_get_match_data() returns NULL.

Fixes: 4d395cb071a3 ("Input: goodix_berlin - add support for Berlin-A series")
Closes: https://sashiko.dev/#/bug/linux-59243248-bebc-4f35-8608-d25e5ec38f26
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/touchscreen/goodix_berlin_i2c.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/goodix_berlin_i2c.c b/drivers/input/touchscreen/goodix_berlin_i2c.c
index 929090a094bf..7c85415ea409 100644
--- a/drivers/input/touchscreen/goodix_berlin_i2c.c
+++ b/drivers/input/touchscreen/goodix_berlin_i2c.c
@@ -36,6 +36,9 @@ static int goodix_berlin_i2c_probe(struct i2c_client *client)
 	struct regmap *regmap;
 	int error;
 
+	if (!ic_data)
+		return -EINVAL;
+
 	regmap = devm_regmap_init_i2c(client, &goodix_berlin_i2c_regmap_conf);
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size
  2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
                   ` (8 preceding siblings ...)
  2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
@ 2026-11-27 20:10 ` Lee Jones
  9 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2026-11-27 20:10 UTC (permalink / raw)
  To: lee, Hans de Goede, Dmitry Torokhov, Neil Armstrong, Jeff LaBundy,
	Jens Reidel, linux-input, linux-kernel
  Cc: stable

goodix_berlin_spi_probe() dereferences ic_data without checking
spi_get_device_match_data() for NULL, and subtracts the SPI read and
write prefix lengths from spi_max_transfer_size() without checking that
max_size exceeds both prefix lengths.  A controller reporting a small
maximum transfer size causes an unsigned size_t underflow (or zero
max_raw_read/write), bypassing regmap transfer chunking.

Return -EINVAL if ic_data is NULL or if max_size is not strictly greater
than both the read and write prefix lengths.

Fixes: 3aa182bbc5b6 ("Input: goodix-berlin - add SPI support for Goodix Berlin Touchscreen IC")
Fixes: 4d395cb071a3 ("Input: goodix_berlin - add support for Berlin-A series")
Closes: https://sashiko.dev/#/bug/linux-a8b8e506-08b4-44c4-bf67-3c8ef31c6da7
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/touchscreen/goodix_berlin_spi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/input/touchscreen/goodix_berlin_spi.c b/drivers/input/touchscreen/goodix_berlin_spi.c
index 01f850f484c2..377c81a3e3c5 100644
--- a/drivers/input/touchscreen/goodix_berlin_spi.c
+++ b/drivers/input/touchscreen/goodix_berlin_spi.c
@@ -133,6 +133,9 @@ static int goodix_berlin_spi_probe(struct spi_device *spi)
 	size_t max_size;
 	int error = 0;
 
+	if (!ic_data)
+		return -EINVAL;
+
 	spi->mode = SPI_MODE_0;
 	spi->bits_per_word = 8;
 	error = spi_setup(spi);
@@ -140,6 +143,9 @@ static int goodix_berlin_spi_probe(struct spi_device *spi)
 		return error;
 
 	max_size = spi_max_transfer_size(spi);
+	if (max_size <= max_t(size_t, ic_data->read_prefix_len,
+			      GOODIX_BERLIN_SPI_WRITE_PREFIX_LEN))
+		return -EINVAL;
 
 	regmap_config = goodix_berlin_spi_regmap_conf;
 	regmap_config.max_raw_read = max_size - ic_data->read_prefix_len;
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure
  2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
@ 2026-11-27 20:24   ` sashiko-bot
  0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-11-27 20:24 UTC (permalink / raw)
  To: Lee Jones, linux-input; +Cc: dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] Input: xpad - pad_present desync in xpad360w_start_input() on
  resume error
--

commit 0f7d5d5809640aae808009f6e404e8e6aa6dfa66
Author: Lee Jones <lee@kernel.org>

Input: xpad - cancel presence work on xpad360w_start_input() failure

This commit cancels xpad->work when xpad_inquiry_pad_presence() fails in
xpad360w_start_input() and cleans up any created input device and output
URBs if xpad360w_start_input() fails during xpad_probe().

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 86f4e756a7fc4..ba0f5684f3d66 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -1880,6 +1880,7 @@ static int xpad360w_start_input(struct usb_xpad *xpad)
>  	error = xpad_inquiry_pad_presence(xpad);
>  	if (error) {
>  		usb_kill_urb(xpad->irq_in);
> +		cancel_work_sync(&xpad->work);
>  		return error;
>  	}

[Severity: Medium]
Can cancel_work_sync(&xpad->work) leave xpad->pad_present out of sync with
xpad->input_created when xpad360w_start_input() fails during xpad_resume()?

xpad360w_process_packet() updates xpad->pad_present in the URB completion
callback before scheduling xpad->work:

drivers/input/joystick/xpad.c:xpad360w_process_packet() {
    ...
		if (xpad->pad_present != present) {
			xpad->pad_present = present;
			schedule_work(&xpad->work);
		}
    ...
}

When xpad_resume() calls xpad360w_start_input() on a live struct usb_xpad
and xpad_inquiry_pad_presence() fails after an incoming packet has already
flipped xpad->pad_present and queued xpad->work, cancelling the pending
work item without running xpad_presence_work() leaves xpad->pad_present in
the new state while xpad->input_created and xpad->x360w_dev remain in the
old state.

Depending on which transition was cancelled, later connection reports are
either ignored because xpad->pad_present is stuck at true, or cause a
later connection to call xpad_init_input() again while xpad->input_created
is already true, overwriting xpad->dev and xpad->led and leaking the
previous input and LED devices.  Using flush_work(&xpad->work) here (as
xpad360w_stop_input() does) would allow any queued transition to complete.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127201050.3532488-1-lee@kernel.org?part=3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs
  2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
@ 2026-11-27 20:35   ` David Heidelberg
  0 siblings, 0 replies; 13+ messages in thread
From: David Heidelberg @ 2026-11-27 20:35 UTC (permalink / raw)
  To: Lee Jones, Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue,
	Andi Shyti, Rob Herring, Javier Martinez Canillas, linux-input,
	linux-stm32, linux-arm-kernel, linux-kernel
  Cc: stable

On 27/11/2026 21:09, Lee Jones wrote:
> i2c_smbus_read_i2c_block_data() returns the positive byte count on
> success or a negative error code on failure.  stmfts_sysfs_read_status()
> checks if (err) and returns err directly, so a normal 4-byte read
> returns 4 without formatting buf (exposing unpopulated sysfs buffer
> bytes), while a 0-byte read formats uninitialised stack memory.
> 
> Return negative errors immediately and require sizeof(status) bytes to
> be read, matching stmfts_read_system_info().
> 
> Fixes: 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")
> Closes: https://sashiko.dev/#/bug/linux-bd87edf0-6f79-4318-8780-d69205787e7d
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>   drivers/input/touchscreen/stmfts.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
> index 2054c2254947..aada03f96940 100644
> --- a/drivers/input/touchscreen/stmfts.c
> +++ b/drivers/input/touchscreen/stmfts.c
> @@ -699,9 +699,12 @@ static ssize_t stmfts_sysfs_read_status(struct device *dev,
>   
>   	err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_STATUS,
>   					    sizeof(status), status);
> -	if (err)
> +	if (err < 0)
>   		return err;
>   
> +	if (err != sizeof(status))
> +		return -EIO;
> +
>   	return sysfs_emit(buf, "%#02x\n", status[0]);
>   }
>   

Reviewed-by: David Heidelberg <david@ixit.cz>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-27 20:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
2026-11-27 20:24   ` sashiko-bot
2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
2026-11-27 20:35   ` David Heidelberg
2026-11-27 20:10 ` [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing Lee Jones
2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
2026-11-27 20:10 ` [PATCH 08/10] Input: drv2667 " Lee Jones
2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox