Commit d802d848 authored by Benoît Sevens's avatar Benoît Sevens Committed by Jiri Kosina
Browse files

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: default avatarBenoît Sevens <bsevens@google.com>
Reviewed-by: default avatarSilvan Jegen <s.jegen@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 48e91af0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;