Archive-only list for patches
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Federico Kirschbaum <federico.kirschbaum@xbow.com>,
	Baul Lee <baul.lee@xbow.com>, Jiri Kosina <jkosina@suse.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 53/91] HID: pidff: fix OOB write when hid->inputs is empty
Date: Mon, 31 Aug 2026 15:34:41 +0200	[thread overview]
Message-ID: <20260831133402.495097310@linuxfoundation.org> (raw)
In-Reply-To: <20260831133359.468089036@linuxfoundation.org>

6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Baul Lee <baul.lee@xbow.com>

[ Upstream commit 67bb1074e3d2d12fa059a9cc707e89398a4e4704 ]

hid_pidff_init_with_quirks() derives its input_dev from

	list_entry(hid->inputs.next, struct hid_input, list)

without first checking that hid->inputs is non-empty.  The list member
of struct hid_input is at offset 0, so on an empty list list_entry()
yields &hid->inputs itself and the following hidinput->input load reads
an unrelated member of struct hid_device.  dev is then a type-confused
pointer, and force-feedback init writes through it: each
set_bit(FF_*, dev->ffbit) stores 8 bytes at dev + 192, past the end of
the object dev actually aliases, and input_ff_create() adds further
writes of a heap pointer and two function pointers.

Until hid-universal-pidff the only caller was hid_pidff_init() from
usbhid, which runs under HID_CLAIMED_INPUT and therefore always has at
least one hid_input.  universal_pidff_probe() starts the device with
HID_CONNECT_DEFAULT & ~HID_CONNECT_FF and then calls
hid_pidff_init_with_quirks() directly whenever the descriptor carries a
PID usage page, bypassing that gate.  A report descriptor whose only
application collection is on HID_UP_PID leaves hid->inputs empty while
hid_connect() still succeeds through the hidraw claim, so probe reaches
the unguarded list_entry().

The write happens in the USB probe path, on the hotplug workqueue, so
plugging in a malicious device is enough to trigger it; no attacker
software and no logged-in user are required.  KASAN reports an 8-byte
out-of-bounds write in hid_pidff_init_with_quirks() reached from
universal_pidff_probe().

Check for an empty list before deriving dev and return -ENODEV, as the
other HID force-feedback drivers already do.  universal_pidff_probe()
propagates the error and unwinds.

Discovered by XBOW, triaged by Baul Lee <baul.lee@xbow.com>

Fixes: f06bf8d94fff ("HID: Add hid-universal-pidff driver and supported device ids")
Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Reported-by: Baul Lee <baul.lee@xbow.com>
Cc: stable@vger.kernel.org
Signed-off-by: Baul Lee <baul.lee@xbow.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hid/usbhid/hid-pidff.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -1298,13 +1298,20 @@ static int pidff_check_autocenter(struct
 int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks)
 {
 	struct pidff_device *pidff;
-	struct hid_input *hidinput =
-		list_entry(hid->inputs.next, struct hid_input, list);
-	struct input_dev *dev = hidinput->input;
+	struct hid_input *hidinput;
+	struct input_dev *dev;
 	struct ff_device *ff;
 	int max_effects;
 	int error;
 
+	if (list_empty(&hid->inputs)) {
+		hid_err(hid, "no inputs found\n");
+		return -ENODEV;
+	}
+
+	hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
+	dev = hidinput->input;
+
 	hid_dbg(hid, "starting pid init\n");
 
 	if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) {



  parent reply	other threads:[~2026-08-31 13:56 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 13:33 [PATCH 6.6 00/91] 6.6.156-rc1 review Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 01/91] RDMA/rxe: Fix OOB in free_rd_atomic_resources() Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 02/91] KVM: x86/mmu: Check write tracking in all address spaces Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 03/91] ext4: dont enable DAX on new encrypted files Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 04/91] io_uring/io-wq: fix worker accounting when canceling creation callbacks Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 05/91] Revert "usb: phy: fsl-usb: Fix use-after-free in delayed work during device removal" Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 06/91] bpf: Ensure reg is PTR_TO_STACK in process_iter_arg Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 07/91] perf: Reject exited events as group leaders Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 08/91] bpf: Remove tst_run from lwt_seg6local_prog_ops Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 09/91] jfs: add check read-only before truncation in jfs_truncate_nolock() Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 10/91] jfs: add check read-only before txBeginAnon() call Greg Kroah-Hartman
2026-08-31 13:33 ` [PATCH 6.6 11/91] ibmvnic: Use kernel helpers for hex dumps Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 12/91] jfs: Fix null-ptr-deref in jfs_ioc_trim Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 13/91] exfat: fix double free in delayed_free Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 14/91] media: platform: exynos4-is: Add hardware sync wait to fimc_is_hw_change_mode() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 15/91] mISDN: hfcpci: Fix warning when deleting uninitialized timer Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 16/91] can: j1939: implement NETDEV_UNREGISTER notification handler Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 17/91] can: j1939: add missing calls in " Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 18/91] can: j1939: make j1939_sk_bind() fail if device is no longer registered Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 19/91] smc: Fix use-after-free in __pnet_find_base_ndev() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 20/91] KVM: arm64: Prevent access to vCPU events before init Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 21/91] smc: Use __sk_dst_get() and dst_dev_rcu() in in smc_clc_prfx_set() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 22/91] smc: Use __sk_dst_get() and dst_dev_rcu() in smc_clc_prfx_match() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 23/91] ASoC: nau8821: Cancel delayed work on component remove Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 24/91] bpf: Fix use-after-free in offloaded map/prog info fill Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 25/91] riscv: Fix register corruption from uninitialized cregs on error Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 26/91] Revert "PM: sleep: Use complete() in device_pm_sleep_init()" Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 27/91] ASoC: nau8821: Cancel pending work before suspend Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 28/91] smc: Use __sk_dst_get() and dst_dev_rcu() in smc_vlan_by_tcpsk() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 29/91] selinux: switch two allocations to use kzalloc_objs() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 30/91] net/sched: Fix mirred deadlock on device recursion Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 31/91] net/sched: initialize noop_qdisc owner Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 32/91] powerpc/hv-gpci: fix preempt count leak in sysfs show paths Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 33/91] crypto: starfive - Do not free stack buffer Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 34/91] ksmbd: harden file lifetime during session teardown Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 35/91] ext4: make state in ext4_mb_mark_bb to be bool Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 36/91] ext4: make some fast commit functions reuse extents path Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 37/91] ext4: propagate errors from fast commit range replay Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 38/91] nilfs2: correct return value kernel-doc descriptions for ioctl functions Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 39/91] nilfs2: reject invalid block index in GC ioctl Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 40/91] nfc: nci: add data_len bound checks to activation parameter extractors Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 41/91] HID: magicmouse: re-enable multitouch after reset-resume Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 42/91] HID: magicmouse: prevent unbounded recursion in magicmouse_raw_event() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 43/91] nvme: rename nvme_sc_to_pr_err to nvme_status_to_pr_err Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 44/91] nvme: fix status magic numbers Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 45/91] nvme: rename CDR/MORE/DNR to NVME_STATUS_* Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 46/91] nvmet-tcp: bound SGL data length before allocating command buffers Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 47/91] HID: nintendo: stop device IO before hid_hw_stop on probe failure Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 48/91] HID: ft260: validate i2c input report length Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 49/91] HID: ft260: fix stack-use-after-return write in I2C read race Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 50/91] HID: uclogic: fix use-after-free of inrange_timer on remove Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 51/91] HID: pidff: Support device error response from PID_BLOCK_LOAD Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 52/91] HID: pidff: clang-format pass Greg Kroah-Hartman
2026-08-31 13:34 ` Greg Kroah-Hartman [this message]
2026-08-31 13:34 ` [PATCH 6.6 54/91] Bluetooth: hci_sync: Use bt_dev_err() to log error message in hci_update_event_filter_sync() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 55/91] Bluetooth: hci_sync: Fix accept list UAF during suspend Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 56/91] xfs: remove file_path tracepoint data Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 57/91] fpga: dfl: fme: add error handling Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 58/91] accessibility: speakup: unregister tty ldisc on later init failures Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 59/91] usb: xhci: Handle USB3 port events when there is one roothub Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 60/91] xhci: dbgtty: Fix unregister on tty_register_driver() failure Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 61/91] xhci: dbgtty: Fix unregister on tty_alloc_driver() failure Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 62/91] fuse: fix invalidate lock leak on setattr writeback failure Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 63/91] fuse: fix invalidate lock leak on open O_TRUNC DAX failure Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 64/91] usb: usbtest: disable dynamic ID support Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 65/91] usb: gadget: f_tcm: keep port count until LUN teardown completes Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 66/91] tls: device: fix out-of-bounds write in tls_append_frag() Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 67/91] x86/CPU/AMD: Add X86_FEATURE_ZEN5 Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 68/91] x86/CPU/AMD: Add more models to X86_FEATURE_ZEN5 Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 69/91] x86/CPU/AMD: Add models 0x10-0x1f to the Zen5 range Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 70/91] x86/CPU/AMD: Add models 0x60-0x6f " Greg Kroah-Hartman
2026-08-31 13:34 ` [PATCH 6.6 71/91] x86/CPU/AMD: Carve out a Zen5 models range Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 72/91] xfrm: espintcp: fix UAF during close Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 73/91] xfrm: drop ESP-in-TCP packets with no ingress device Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 74/91] xfrm: ah6: validate routing header segments_left Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 75/91] xfrm: fix xfrm_state_construct() auth-trunc leak Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 76/91] net: bridge: mcast: fix use-after-free of a master VLANs multicast context Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 77/91] ipv6: seg6: clear IPv4 control block on IPIP decapsulation Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 78/91] mm/swap: reject swapon() on filesystem-level encrypted files Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 79/91] crypto: atmel-tdes - use scatterlist length before DMA mapping Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 80/91] crypto: qce - fix CCM AAD buffer underallocation Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 81/91] crypto: mxs-dcp - fix source scatterlist length access Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 82/91] crypto: qce - Remove unsafe/deprecated algorithms Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 83/91] KVM: s390: vsie: zero stale crypto bits Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 84/91] usb: core: Add lock to usb_wakeup_notification() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 85/91] usb: core: Strengthen error handling in hub_hub_status() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 86/91] ALSA: usb-audio: fix OOB write in snd_usbmidi_novation_output() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 87/91] ALSA: usb-audio: Complete cleanup after system-resume errors Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 88/91] USB: serial: option: fix slab OOB read in interrupt URB callback Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 89/91] USB: serial: spcp8x5: drop broken carrier detect support Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 90/91] USB: c67x00: fix use-after-free in c67x00_add_iso_urb() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 6.6 91/91] usb: usbfs: fix use-after-free of usb_device in usbdev_release() Greg Kroah-Hartman
2026-08-31 18:16 ` [PATCH 6.6 00/91] 6.6.156-rc1 review Francesco Dolcini
2026-08-31 18:21 ` Florian Fainelli
2026-08-31 19:07 ` Wentao Guan
2026-08-31 19:12 ` Brett A C Sheffield
2026-08-31 21:01 ` Peter Schneider
2026-09-01  8:44 ` Pavel Machek
2026-09-01 16:46 ` Shuah Khan
2026-09-01 23:19 ` Ron Economos
2026-09-02  3:39 ` Barry K. Nathan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260831133402.495097310@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=baul.lee@xbow.com \
    --cc=federico.kirschbaum@xbow.com \
    --cc=jkosina@suse.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox