]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Input: powermate - fix use-after-free in powermate_config_complete
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Sat, 14 Oct 2023 03:11:33 +0000 (20:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 09:13:30 +0000 (11:13 +0200)
commit8677575c4f39d65bf0d719b5d20e8042e550ccb9
tree1ac4e67e11282cb0fbdf02f50b8e0a6fc3a208d5
parente329f6f77baf3ae6a9998c88deb06a0b27caaf95
Input: powermate - fix use-after-free in powermate_config_complete

commit 5c15c60e7be615f05a45cd905093a54b11f461bc upstream.

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

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reported-by: syzbot+0434ac83f907a1dbdd1e@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20230916-topic-powermate_use_after_free-v3-1-64412b81a7a2@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/input/misc/powermate.c