From: syzbot <syzbot+9cb1ac7fce4944ba9165@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Write in bus_for_each_drv
Date: Mon, 24 Aug 2026 00:00:50 -0700 [thread overview]
Message-ID: <6a8bec22.dbb3a75c.13dd47.0063.GAE@google.com> (raw)
In-Reply-To: <6a7919c6.9c11d2ce.289b96.00de.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Write in bus_for_each_drv
Author: kmehltretter@gmail.com
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
Please test the following patch on the known-good upstream revision from
the original report.
---
lib/klist.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lib/klist.c b/lib/klist.c
index 332a4fbf18ff0..e503031cd1f9d 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -36,6 +36,7 @@
#include <linux/klist.h>
#include <linux/export.h>
#include <linux/sched.h>
+#include <linux/sched/task.h>
/*
* Use the lowest bit of n_klist to mark deleted nodes and exclude
@@ -187,18 +188,25 @@ static void klist_release(struct kref *kref)
WARN_ON(!knode_dead(n));
list_del(&n->n_node);
+ /* The woken caller may free or reuse n. */
+ knode_set_klist(n, NULL);
spin_lock(&klist_remove_lock);
list_for_each_entry_safe(waiter, tmp, &klist_remove_waiters, list) {
+ struct task_struct *p;
+
if (waiter->node != n)
continue;
+ /* Pin the task before the waiter can return. */
+ p = waiter->process;
+ get_task_struct(p);
list_del(&waiter->list);
- waiter->woken = 1;
- mb();
- wake_up_process(waiter->process);
+ /* Publish after the last accesses to waiter and n. */
+ smp_store_release(&waiter->woken, 1);
+ wake_up_process(p);
+ put_task_struct(p);
}
spin_unlock(&klist_remove_lock);
- knode_set_klist(n, NULL);
}
static int klist_dec_and_del(struct klist_node *n)
@@ -251,6 +259,7 @@ void klist_remove(struct klist_node *n)
for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE);
- if (waiter.woken)
+ /* Pairs with the release store in klist_release(). */
+ if (smp_load_acquire(&waiter.woken))
break;
schedule();
}
prev parent reply other threads:[~2026-08-24 7:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 0:22 [syzbot] [kernel?] KASAN: slab-use-after-free Write in bus_for_each_drv syzbot
2026-08-10 22:39 ` syzbot
2026-08-23 21:54 ` Forwarded: " syzbot
2026-08-24 1:53 ` syzbot
2026-08-24 7:00 ` syzbot [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=6a8bec22.dbb3a75c.13dd47.0063.GAE@google.com \
--to=syzbot+9cb1ac7fce4944ba9165@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
/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