mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+a56aa983ce6a1bf12485@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in driver_remove_file
Date: Sun, 21 Sep 2025 20:38:24 +0800	[thread overview]
Message-ID: <20250921123825.7352-1-hdanton@sina.com> (raw)
In-Reply-To: <68cf794c.050a0220.13cd81.002a.GAE@google.com>

> Date: Sat, 20 Sep 2025 21:04:28 -0700
> syzbot has found a reproducer for the following issue on:
> 
> HEAD commit:    3b08f56fbbb9 Merge tag 'x86-urgent-2025-09-20' of git://gi..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=14ce5858580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8f01d8629880e620
> dashboard link: https://syzkaller.appspot.com/bug?extid=a56aa983ce6a1bf12485
> compiler:       gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15571534580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=152f7e42580000

#syz test

--- x/drivers/comedi/drivers.c
+++ y/drivers/comedi/drivers.c
@@ -961,7 +961,7 @@ EXPORT_SYMBOL_GPL(comedi_legacy_detach);
 int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
 	struct comedi_driver *driv;
-	int ret;
+	int ret, detach;
 
 	lockdep_assert_held(&dev->mutex);
 	if (dev->attached)
@@ -1004,11 +1004,15 @@ int comedi_device_attach(struct comedi_d
 	dev->driver = driv;
 	dev->board_name = dev->board_ptr ? *(const char **)dev->board_ptr
 					 : dev->driver->driver_name;
+	detach = 0;
 	ret = driv->attach(dev, it);
-	if (ret >= 0)
+	if (ret >= 0) {
+		detach = 1;
 		ret = comedi_device_postconfig(dev);
+	}
 	if (ret < 0) {
-		comedi_device_detach(dev);
+		if (detach)
+			comedi_device_detach(dev);
 		module_put(driv->module);
 	}
 	/* On success, the driver module count has been incremented. */
--

  parent reply	other threads:[~2025-09-21 12:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 11:26 syzbot
2025-09-21  4:04 ` syzbot
2025-09-21 11:22   ` Edward Adam Davis
2025-09-21 11:40     ` syzbot
2025-09-21 11:55   ` Edward Adam Davis
2025-09-21 12:20     ` syzbot
2025-09-21 12:20   ` [PATCH] comedi: Unregister is prohibited when attach fails before register Edward Adam Davis
2025-09-21 12:38   ` Hillf Danton [this message]
2025-09-21 13:06     ` [syzbot] [fs?] KASAN: slab-use-after-free Read in driver_remove_file syzbot
2026-01-05  9:58 ` syzbot
2026-01-06 10:30 ` Forwarded: " syzbot
2025-09-24  6:31 [syzbot] [fs?] KASAN: slab-use-after-free Read in bus_remove_driver syzbot
2025-09-24  7:22 ` [syzbot] [fs?] KASAN: slab-use-after-free Read in driver_remove_file Edward Adam Davis

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=20250921123825.7352-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+a56aa983ce6a1bf12485@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

all inboxes | Powered by JetHome®