public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	syzbot+0434ac83f907a1dbdd1e@syzkaller.appspotmail.com,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 7/7] Input: powermate - fix use-after-free in powermate_config_complete
Date: Wed, 18 Oct 2023 10:15:23 -0400	[thread overview]
Message-ID: <20231018141525.1335533-7-sashal@kernel.org> (raw)
In-Reply-To: <20231018141525.1335533-1-sashal@kernel.org>

From: Javier Carrasco <javier.carrasco.cruz@gmail.com>

[ Upstream commit 5c15c60e7be615f05a45cd905093a54b11f461bc ]

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: Sasha Levin <sashal@kernel.org>
---
 drivers/input/misc/powermate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c
index c4e0e1886061f..6b1b95d58e6b5 100644
--- a/drivers/input/misc/powermate.c
+++ b/drivers/input/misc/powermate.c
@@ -425,6 +425,7 @@ static void powermate_disconnect(struct usb_interface *intf)
 		pm->requires_update = 0;
 		usb_kill_urb(pm->irq);
 		input_unregister_device(pm->input);
+		usb_kill_urb(pm->config);
 		usb_free_urb(pm->irq);
 		usb_free_urb(pm->config);
 		powermate_free_buffers(interface_to_usbdev(intf), pm);
-- 
2.40.1


      parent reply	other threads:[~2023-10-18 15:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 14:15 [PATCH AUTOSEL 5.4 1/7] Input: i8042 - add Fujitsu Lifebook E5411 to i8042 quirk table Sasha Levin
2023-10-18 14:15 ` [PATCH AUTOSEL 5.4 2/7] workqueue: Fix UAF report by KASAN in pwq_release_workfn() Sasha Levin
2023-10-18 14:15 ` [PATCH AUTOSEL 5.4 3/7] irqchip/stm32-exti: add missing DT IRQ flag translation Sasha Levin
2023-10-18 14:15 ` [PATCH AUTOSEL 5.4 4/7] dmaengine: ste_dma40: Fix PM disable depth imbalance in d40_probe Sasha Levin
2023-10-18 14:15 ` [PATCH AUTOSEL 5.4 5/7] Input: synaptics-rmi4 - handle reset delay when using SMBus trsnsport Sasha Levin
2023-10-18 14:15 ` [PATCH AUTOSEL 5.4 6/7] Input: xpad - add PXN V900 support Sasha Levin
2023-10-18 14:15 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231018141525.1335533-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+0434ac83f907a1dbdd1e@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox