Skip to content

Commit d802d84

Browse files
dlelcldkeksleleJiri Kosina
authored andcommitted
HID: roccat: fix use-after-free in roccat_report_event
roccat_report_event() iterates over the device->readers list without holding the readers_lock. This allows a concurrent roccat_release() to remove and free a reader while it's still being accessed, leading to a use-after-free. Protect the readers list traversal with the readers_lock mutex. Signed-off-by: Benoît Sevens <bsevens@google.com> Reviewed-by: Silvan Jegen <s.jegen@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 48e91af commit d802d84

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hid/hid-roccat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ int roccat_report_event(int minor, u8 const *data)
257257
if (!new_value)
258258
return -ENOMEM;
259259

260+
mutex_lock(&device->readers_lock);
260261
mutex_lock(&device->cbuf_lock);
261262

262263
report = &device->cbuf[device->cbuf_end];
@@ -279,6 +280,7 @@ int roccat_report_event(int minor, u8 const *data)
279280
}
280281

281282
mutex_unlock(&device->cbuf_lock);
283+
mutex_unlock(&device->readers_lock);
282284

283285
wake_up_interruptible(&device->wait);
284286
return 0;

0 commit comments

Comments
 (0)