From: syzbot <syzbot+c492a9e154f81127551f@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] HID: roccat: fix use-after-free in roccat_disconnect()
Date: Wed, 02 Sep 2026 16:07:36 -0700 [thread overview]
Message-ID: <6a98ac38.2e567484.299ffc.0002.GAE@google.com> (raw)
In-Reply-To: <6a987197.9266084e.bf0d7.000d.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] HID: roccat: fix use-after-free in roccat_disconnect()
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
roccat_disconnect() dropped devices_lock between reading device->exist
and later checking device->open to decide whether to free the device.
This let a concurrent roccat_release() see exist == 0 and free the
device first, so roccat_disconnect()'s later device->open check ran on
freed memory.
Fix this by performing the whole lookup, exist/devices[] update, and
free-or-keep decision inside a single devices_lock critical section,
matching what roccat_release() already does.
Reported-by: syzbot+c492a9e154f81127551f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c492a9e154f81127551f
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/hid/hid-roccat.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index 4f15eb951039..984f7c334f14 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -369,15 +369,12 @@ void roccat_disconnect(int minor)
mutex_lock(&devices_lock);
device = devices[minor];
- mutex_unlock(&devices_lock);
device->exist = 0; /* TODO exist maybe not needed */
device_destroy(device->dev->class, MKDEV(roccat_major, minor));
- mutex_lock(&devices_lock);
devices[minor] = NULL;
- mutex_unlock(&devices_lock);
if (device->open) {
hid_hw_close(device->hid);
@@ -385,6 +382,8 @@ void roccat_disconnect(int minor)
} else {
roccat_free_device(device);
}
+
+ mutex_unlock(&devices_lock);
}
EXPORT_SYMBOL_GPL(roccat_disconnect);
--
2.43.0
next prev parent reply other threads:[~2026-09-02 23:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 18:57 [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in roccat_disconnect syzbot
2026-09-02 23:07 ` syzbot [this message]
2026-09-02 23:48 ` Forwarded: [PATCH] HID: roccat: fix use-after-free and uninitialized-mutex races syzbot
2026-09-29 6:32 ` Forwarded: #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e syzbot
2026-10-16 10:42 ` Forwarded: #syz test https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-7.4/roccat syzbot
2026-10-16 11:06 ` syzbot
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=6a98ac38.2e567484.299ffc.0002.GAE@google.com \
--to=syzbot+c492a9e154f81127551f@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.