public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+0154da2d403396b2bd59@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in steam_input_open
Date: Mon, 24 Feb 2025 18:41:13 +0800	[thread overview]
Message-ID: <20250224104114.2781-1-hdanton@sina.com> (raw)
In-Reply-To: <67ba02e3.050a0220.14d86d.065b.GAE@google.com>

On Sat, 22 Feb 2025 09:01:23 -0800
> syzbot found the following issue on:
> 
> HEAD commit:    0a86e49acfbb dt-bindings: usb: samsung,exynos-dwc3 Add exy..
> git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17c02ba4580000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master

--- x/drivers/hid/hid-steam.c
+++ y/drivers/hid/hid-steam.c
@@ -313,6 +313,7 @@ struct steam_device {
 	u16 rumble_left;
 	u16 rumble_right;
 	unsigned int sensor_timestamp_us;
+	unsigned int dead;
 	struct work_struct unregister_work;
 };
 
@@ -618,6 +619,8 @@ static void steam_input_close(struct inp
 	unsigned long flags;
 	bool set_lizard_mode;
 
+	if (dev->going_away)
+		return;
 	if (!(steam->quirks & STEAM_QUIRK_DECK)) {
 		spin_lock_irqsave(&steam->lock, flags);
 		set_lizard_mode = !steam->client_opened && lizard_mode;
@@ -1140,6 +1143,10 @@ static int steam_client_ll_open(struct h
 	unsigned long flags;
 
 	spin_lock_irqsave(&steam->lock, flags);
+	if (steam->dead) {
+		spin_unlock_irqrestore(&steam->lock, flags);
+		return -ENODEV;
+	}
 	steam->client_opened++;
 	spin_unlock_irqrestore(&steam->lock, flags);
 
@@ -1156,6 +1163,10 @@ static void steam_client_ll_close(struct
 	bool connected;
 
 	spin_lock_irqsave(&steam->lock, flags);
+	if (steam->dead) {
+		spin_unlock_irqrestore(&steam->lock, flags);
+		return;
+	}
 	steam->client_opened--;
 	connected = steam->connected && !steam->client_opened;
 	spin_unlock_irqrestore(&steam->lock, flags);
@@ -1321,11 +1332,15 @@ err_cancel_work:
 static void steam_remove(struct hid_device *hdev)
 {
 	struct steam_device *steam = hid_get_drvdata(hdev);
+	unsigned long flags;
 
 	if (!steam || hdev->group == HID_GROUP_STEAM) {
 		hid_hw_stop(hdev);
 		return;
 	}
+	spin_lock_irqsave(&steam->lock, flags);
+	steam->dead++;
+	spin_unlock_irqrestore(&steam->lock, flags);
 
 	cancel_delayed_work_sync(&steam->mode_switch);
 	cancel_work_sync(&steam->work_connect);
@@ -1350,6 +1365,8 @@ static void steam_do_connect_event(struc
 	spin_lock_irqsave(&steam->lock, flags);
 	changed = steam->connected != connected;
 	steam->connected = connected;
+	if (steam->dead)
+		changed = false;
 	spin_unlock_irqrestore(&steam->lock, flags);
 
 	if (changed && schedule_work(&steam->work_connect) == 0)
--

  parent reply	other threads:[~2025-02-24 10:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-22 17:01 [syzbot] [input?] [usb?] KASAN: slab-use-after-free Read in steam_input_open syzbot
2025-02-23  0:27 ` Hillf Danton
2025-02-23  1:24   ` syzbot
2025-02-23  2:54 ` Hillf Danton
2025-02-23  3:47   ` syzbot
2025-02-23  7:29 ` Hillf Danton
2025-02-23  7:52   ` syzbot
2025-02-23  9:03 ` Hillf Danton
2025-02-23  9:17   ` syzbot
2025-02-23  9:22 ` Edward Adam Davis
2025-02-23  9:51   ` syzbot
2025-02-23 11:39 ` Hillf Danton
2025-02-23 11:56   ` syzbot
2025-02-23 11:45 ` Vicki Pfau
2025-02-23 13:25 ` Edward Adam Davis
2025-02-23 13:43   ` syzbot
2025-02-23 14:15 ` Edward Adam Davis
2025-02-23 14:27   ` syzbot
2025-02-23 14:31 ` Edward Adam Davis
2025-02-23 14:48   ` syzbot
2025-02-24  4:54 ` Hillf Danton
2025-02-24  5:21   ` syzbot
2025-02-24 10:41 ` Hillf Danton [this message]
2025-02-24 11:47   ` syzbot
2025-02-24 12:04 ` Edward Adam Davis
2025-02-24 12:19   ` syzbot
2025-02-24 12:24 ` Edward Adam Davis
2025-02-24 12:44   ` syzbot

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=20250224104114.2781-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+0154da2d403396b2bd59@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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