From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3AEC31E84F for ; Mon, 24 Aug 2026 01:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787536422; cv=none; b=QBI8hIhaMlf11FbPYcDU809MPiu/WmiCyAnjptQfsCal0vst15g+uV2tF677F0+qtsD/GwXe/5TDO3S7G9ph8bFalKAA+Wt5JTPCkuO9DWjM3llMVwklPeyQSWNCoM4vruV7fmv7v2XjTo/BDknXQGzZ90Z4HH9medTRET6x3Rg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787536422; c=relaxed/simple; bh=Ad7MCTVIJHE50Yd+EuBO7mEm/2uxCT3AWHQeaMwZa0I=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=MgOhNhWN07QGw5fvgPibLNPERGWdF2iYPDy5bazo39bjvtCEtk9ompGn3t7pv9CDMm/zc5SnghHeaS0afvo97zj68QNEZUKneobjU1HWteKElbLsfV3fRLbJ3qdETC6yXf3gGEHmRsG54/kTJIyj3K8eD6/ezWQN+sxTBfYqNCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.167.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-4ab4dd46ddeso2353379b6e.3 for ; Sun, 23 Aug 2026 18:53:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787536419; x=1788141219; h=content-type:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=vbBlL60T+zh9Gk/No7GFFL2PgV706ZnzhAWexvxU06g=; b=V9oWFEMBaeQ12PVlK12j7sq47fqeOMPTbwf1CEUomqEt5M4EPbKGGrH6B480m6DweB asnnXWwWYnXFFT2ABexcc3bk2vv4s6lrYK9rUveKd/Kq7JgcYwoD+HDMRHSKOKuc85QX yEyahszx7z04cNExWslbpdav16hGmJjVz1QNcAb1uY9q024cAAL92l6u7KdotMhWYxWN 7/NYm4zPjoCq+BcVT+Uf2R8kcRtTHbmo/FDjMhAWELWvX3Il0t6lbO9ClCzafWeCBG9h NvA1V7xr0QO/k3OKM9KK4TDb/9ao1Gdo5VZJyuLYt+LY6HsnsomzuO3vJ2fzf9FiGs+A ocNA== X-Gm-Message-State: AFuF++lDR/VJmCIehdlLRpqXjMWJOv9bOdxOpsBEWEykIys96oKdqdSE 0Ye1xy8Db2/4u6DChSArTLv0giuKdwLWbCMyswGCshNz7P3jZRdnw0p9ZW3Cygz0AlmM1baDmoC 21HwjyKSVBsANoSa2BylCBQbdSAPX5AjY0MGiXp895KG7kpi2BT404wLURVI= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6808:c166:b0:493:a860:5809 with SMTP id 5614622812f47-4b3099ff6damr16335409b6e.4.1787536419523; Sun, 23 Aug 2026 18:53:39 -0700 (PDT) Date: Sun, 23 Aug 2026 18:53:39 -0700 In-Reply-To: <6a7919c6.9c11d2ce.289b96.00de.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a8ba423.dbb3a75c.13dd47.0059.GAE@google.com> Subject: Forwarded: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Write in bus_for_each_drv From: syzbot To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 #include #include +#include /* * 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(); }