From: syzbot <syzbot+bc537ca7a0efe33988eb@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] HID: core: serialize report_descriptor_read() against probe and remove
Date: Fri, 09 Oct 2026 03:28:28 -0700 [thread overview]
Message-ID: <6ac8c1cc.a150a118.27e199.0023.GAE@google.com> (raw)
In-Reply-To: <683199ed.a70a0220.29d4a0.07f6.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] HID: core: serialize report_descriptor_read() against probe and remove
Author: krishgulati7@gmail.com
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git bdab5605259b
Since commit 54f32fd5dff9 ("HID: Make report_descriptor available for
all devices"), the "report_descriptor" sysfs attribute is part of the
device's attribute group, so it exists from device_add() until
device_del(). It reads hdev->rdesc, but that buffer only lives from
hid_open_report() until hid_close_report(), that is, for the duration
of a driver binding. For a driver with a report_fixup() callback,
rdesc is a private copy that hid_close_report() frees, so a read that
races with the driver being unbound accesses freed memory. syzbot
reports this as:
BUG: KASAN: slab-use-after-free in report_descriptor_read+0xb5/0x100
Read of size 24 at addr ffff888078d61f00 by task fido_id/7281
...
Allocated by task 10:
kmemdup_noprof+0x2b/0x70
hid_open_report+0x1fa/0xf00
lg_probe+0x29c/0x890
hid_device_probe+0x46a/0x870
...
Because hid_close_report() also clears rdesc and rsize, the same missing
serialization can make the reader see a NULL rdesc with a non-zero
rsize.
Hold the device lock in report_descriptor_read(). The driver core
already holds it across probe and remove, so a read can no longer
overlap with them.
Reported-by: syzbot+bc537ca7a0efe33988eb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=bc537ca7a0efe33988eb
Fixes: 54f32fd5dff9 ("HID: Make report_descriptor available for all devices")
Signed-off-by: Krish Gulati <krishgulati7@gmail.com>
---
drivers/hid/hid-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a3ff0514f9cd..824557a02544 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2270,6 +2270,8 @@ report_descriptor_read(struct file *filp, struct kobject *kobj,
struct device *dev = kobj_to_dev(kobj);
struct hid_device *hdev = to_hid_device(dev);
+ guard(device)(dev);
+
if (off >= hdev->rsize)
return 0;
--
2.56.0
prev parent reply other threads:[~2026-10-09 10:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-24 10:05 [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in report_descriptor_read syzbot
2026-08-16 3:03 ` syzbot
2026-10-09 8:52 ` Forwarded: [PATCH] HID: core: serialize report_descriptor_read() against probe and remove syzbot
2026-10-09 10:28 ` syzbot [this message]
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=6ac8c1cc.a150a118.27e199.0023.GAE@google.com \
--to=syzbot+bc537ca7a0efe33988eb@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®