* [PATCH] HID: roccat: fix use-after-free in roccat_report_event
@ 2026-03-23 16:11 FirstName LastName
2026-03-23 20:32 ` Silvan Jegen
2026-03-27 10:28 ` Jiri Kosina
0 siblings, 2 replies; 3+ messages in thread
From: FirstName LastName @ 2026-03-23 16:11 UTC (permalink / raw)
To: Stefan Achatz, Jiri Kosina, Benjamin Tissoires
Cc: linux-input, linux-kernel, Benoît Sevens
From: Benoît Sevens <bsevens@google.com>
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>
---
drivers/hid/hid-roccat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index fd0ea52f7cba..d6fff53d4ee7 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -257,6 +257,7 @@ int roccat_report_event(int minor, u8 const *data)
if (!new_value)
return -ENOMEM;
+ mutex_lock(&device->readers_lock);
mutex_lock(&device->cbuf_lock);
report = &device->cbuf[device->cbuf_end];
@@ -279,6 +280,7 @@ int roccat_report_event(int minor, u8 const *data)
}
mutex_unlock(&device->cbuf_lock);
+ mutex_unlock(&device->readers_lock);
wake_up_interruptible(&device->wait);
return 0;
--
2.53.0.959.g497ff81fa9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: roccat: fix use-after-free in roccat_report_event
2026-03-23 16:11 [PATCH] HID: roccat: fix use-after-free in roccat_report_event FirstName LastName
@ 2026-03-23 20:32 ` Silvan Jegen
2026-03-27 10:28 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Silvan Jegen @ 2026-03-23 20:32 UTC (permalink / raw)
To: FirstName LastName
Cc: Stefan Achatz, Jiri Kosina, Benjamin Tissoires, linux-input,
linux-kernel, Benoît Sevens
Hi
Thanks for the patch! One comment below.
FirstName LastName <bsevens@google.com> wrote:
> From: Benoît Sevens <bsevens@google.com>
>
> 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>
> ---
> drivers/hid/hid-roccat.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
> index fd0ea52f7cba..d6fff53d4ee7 100644
> --- a/drivers/hid/hid-roccat.c
> +++ b/drivers/hid/hid-roccat.c
> @@ -257,6 +257,7 @@ int roccat_report_event(int minor, u8 const *data)
> if (!new_value)
> return -ENOMEM;
>
> + mutex_lock(&device->readers_lock);
As the readers are only accessed later, we could move the locking further
down. Not sure if it's worth it in this case.
Other than that this LGTM!
Reviewed-by: Silvan Jegen <s.jegen@gmail.com>
Cheers,
Silvan
> mutex_lock(&device->cbuf_lock);
>
> report = &device->cbuf[device->cbuf_end];
> @@ -279,6 +280,7 @@ int roccat_report_event(int minor, u8 const *data)
> }
>
> mutex_unlock(&device->cbuf_lock);
> + mutex_unlock(&device->readers_lock);
>
> wake_up_interruptible(&device->wait);
> return 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: roccat: fix use-after-free in roccat_report_event
2026-03-23 16:11 [PATCH] HID: roccat: fix use-after-free in roccat_report_event FirstName LastName
2026-03-23 20:32 ` Silvan Jegen
@ 2026-03-27 10:28 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2026-03-27 10:28 UTC (permalink / raw)
To: FirstName LastName
Cc: Stefan Achatz, Benjamin Tissoires, linux-input, linux-kernel
On Mon, 23 Mar 2026, FirstName LastName wrote:
> From: Benoît Sevens <bsevens@google.com>
>
> 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>
> ---
> drivers/hid/hid-roccat.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
> index fd0ea52f7cba..d6fff53d4ee7 100644
> --- a/drivers/hid/hid-roccat.c
> +++ b/drivers/hid/hid-roccat.c
> @@ -257,6 +257,7 @@ int roccat_report_event(int minor, u8 const *data)
> if (!new_value)
> return -ENOMEM;
>
> + mutex_lock(&device->readers_lock);
> mutex_lock(&device->cbuf_lock);
>
> report = &device->cbuf[device->cbuf_end];
> @@ -279,6 +280,7 @@ int roccat_report_event(int minor, u8 const *data)
> }
>
> mutex_unlock(&device->cbuf_lock);
> + mutex_unlock(&device->readers_lock);
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-27 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 16:11 [PATCH] HID: roccat: fix use-after-free in roccat_report_event FirstName LastName
2026-03-23 20:32 ` Silvan Jegen
2026-03-27 10:28 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox