From: Philipp Weber <kernel@phwe.de>
To: syzbot+9eebf5f6544c5e873858@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in hidraw_report_event
Date: Tue, 19 May 2026 14:52:02 +0200 [thread overview]
Message-ID: <20260519125202.34382-1-kernel@phwe.de> (raw)
In-Reply-To: <69eed7e0.a00a0220.7773.0026.GAE@google.com>
#syz test
Quiesce HID input in hid_hw_stop() when io_started is true, so that
hidraw_report_event() cannot race with the upcoming hid_disconnect()
that frees the hidraw object.
This is a centralized variant of Edward Adam Davis's per-driver fix
("hwmon: prevent packets from going to driver for probe", 2026-04-28).
Of 15 hid_device_io_start() callers in the tree, 8 lack the matching
io_stop() before hid_hw_stop() in their error paths.
---
drivers/hid/hid-core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 41a79e43c82b..6b024118d983 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2440,9 +2440,16 @@ EXPORT_SYMBOL_GPL(hid_hw_start);
*
* This is usually called from remove function or from probe when something
* failed and hid_hw_start was called already.
+ *
+ * If the caller enabled HID input via hid_device_io_start() and is unwinding
+ * without an explicit hid_device_io_stop(), quiesce input first so that
+ * in-flight reports cannot reach handlers (e.g. hidraw_report_event) whose
+ * backing objects hid_disconnect() is about to free.
*/
void hid_hw_stop(struct hid_device *hdev)
{
+ if (hdev->io_started)
+ hid_device_io_stop(hdev);
hid_disconnect(hdev);
hdev->ll_driver->stop(hdev);
}
--
2.53.0
next prev parent reply other threads:[~2026-05-19 12:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 3:28 [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in hidraw_report_event syzbot
2026-04-27 5:05 ` Edward Adam Davis
2026-04-27 6:03 ` syzbot
2026-04-27 9:18 ` Edward Adam Davis
2026-04-27 12:49 ` syzbot
2026-04-27 13:11 ` Edward Adam Davis
2026-04-27 14:09 ` syzbot
2026-04-27 23:21 ` Hillf Danton
2026-04-27 23:57 ` syzbot
2026-04-28 1:04 ` Edward Adam Davis
2026-04-28 4:05 ` syzbot
2026-04-28 3:51 ` Hillf Danton
2026-04-28 4:37 ` syzbot
2026-04-28 4:12 ` [PATCH] hwmon: prevent packets from going to driver for probe Edward Adam Davis
2026-04-28 8:00 ` [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in hidraw_report_event Hillf Danton
2026-04-28 8:51 ` syzbot
2026-04-28 11:33 ` Hillf Danton
2026-04-28 12:03 ` syzbot
2026-04-28 20:27 ` Hillf Danton
2026-04-28 21:19 ` syzbot
2026-05-19 12:52 ` Philipp Weber [this message]
2026-05-19 12:52 ` syzbot
2026-05-19 13:00 ` [RFC PATCH] HID: core: quiesce input in hid_hw_stop() to prevent use-after-free Philipp Weber
2026-06-29 8:48 ` Jiri Kosina
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=20260519125202.34382-1-kernel@phwe.de \
--to=kernel@phwe.de \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+9eebf5f6544c5e873858@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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