Subject: CVE-2023-52475: Input: powermate - fix use-after-free in powermate_config_complete

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

Input: powermate - fix use-after-free in powermate_config_complete

syzbot has found a use-after-free bug [1] in the powermate driver. This
happens when the device is disconnected, which leads to a memory free from
the powermate_device struct.  When an asynchronous control message
completes after the kfree and its callback is invoked, the lock does not
exist anymore and hence the bug.

Use usb_kill_urb() on pm->config to cancel any in-progress requests upon
device disconnection.

[1] https://syzkaller.appspot.com/bug?extid=0434ac83f907a1dbdd1e

The Linux kernel CVE team has assigned CVE-2023-52475 to this issue.

Affected and fixed versions
===========================

	Fixed in 4.14.328 with commit 8677575c4f39
	Fixed in 4.19.297 with commit 67cace72606b
	Fixed in 5.4.259 with commit 5aa514100aaf
	Fixed in 5.10.199 with commit cd2fbfd8b922
	Fixed in 5.15.136 with commit 6a4a39638640
	Fixed in 6.1.59 with commit 2efe67c581a2
	Fixed in 6.5.8 with commit e528b1b9d607
	Fixed in 6.6 with commit 5c15c60e7be6

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2023-52475
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/input/misc/powermate.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/8677575c4f39d65bf0d719b5d20e8042e550ccb9
	https://git.kernel.org/stable/c/67cace72606baf1758fd60feb358f4c6be92e1cc
	https://git.kernel.org/stable/c/5aa514100aaf59868d745196258269a16737c7bd
	https://git.kernel.org/stable/c/cd2fbfd8b922b7fdd50732e47d797754ab59cb06
	https://git.kernel.org/stable/c/6a4a396386404e62fb59bc3bde48871a64a82b4f
	https://git.kernel.org/stable/c/2efe67c581a2a6122b328d4bb6f21b3f36f40d46
	https://git.kernel.org/stable/c/e528b1b9d60743e0b26224e3fe7aa74c24b8b2f8
	https://git.kernel.org/stable/c/5c15c60e7be615f05a45cd905093a54b11f461bc