From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (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 87EFE3E3DBC for ; Mon, 24 Aug 2026 07:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787554853; cv=none; b=jYjJz7W9Bj0NWB8FxhyWpwr5gf784MXuSJON1pPXfBF1WJDy6nPPgleJKnslcBzZK/aHtwiBIjxclG7++vHAWOQf60ZRS81Zu2hiFmBMfNFPxfizSemNRVBTJUMNsPy3NGwI26qNK265YOP2Z/KV7SbgsmrgozR95YJpdrg/2Zk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787554853; c=relaxed/simple; bh=Ad7MCTVIJHE50Yd+EuBO7mEm/2uxCT3AWHQeaMwZa0I=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=HmtQQcG40+MpnJYdiIzux8KXqSeZg03vKIttyZmaVrum51+iOT1L0rN993Jcw5QTtczgiSwoUH0vkRTlJiFyw2Q2o9kuDRoFdBkAXYhGeMASUCGMJslSdnHWJlYIIExYhr+8Mcdi3r8YAOtNIEBrcS6JfY9flAtQpvlgCQDIP9s= 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.160.71 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-oa1-f71.google.com with SMTP id 586e51a60fabf-45ea997c202so4898972fac.1 for ; Mon, 24 Aug 2026 00:00:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787554850; x=1788159650; 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=W+sBxHSh4rppcMr00iqvMsiUyTkm1T7Y/vyNzKZn8jMj1faZjGz/iq2E5HQ9p2GCHh LqgjHpfytOCz2JXJf1XOO5t1i2ItAQG9PWO2LPFgYojusKZLo0uji4eYEznvaLywx4bm 9o53NvBNFE13v+wWKK67Xa0sG5DdFdzMApv2rQXXYVvFS1v8Q52m5KShqvUROdd4qc7E hZcY369V/VDFxultil1qestoyOiAJ7ZzDLs0oHXYVOIQLPmoGu77UTfRMOHd/BOe6lcX Zh8TTMpd+SBeQhJfJ3TcqHxzHg0SekpuZQmdj5Ux8FaoyyyA4bpA5NJXtFzser2E8Bf+ mCJA== X-Gm-Message-State: AFuF++nhKPDmO493hA2Aj4sDwXfbX8c5ZCbZ/+yXbU3lNGIBCiEdOP57 +6+2Gto6UrIk3rYmp7hTFVb9kWaGTORn+HN19sgpTYPv1Orf8bMQRx11H5MYgz+F16x4WasqARi j1wDVGs6vXepBLVzAVakmLAlEsNk/E5kKUBtgEOcVjX3VK5r9wi1w2jmb+pY= 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:6820:c44f:20b0:6aa:1633:7af9 with SMTP id 006d021491bc7-6b159484a62mr16936888eaf.35.1787554850318; Mon, 24 Aug 2026 00:00:50 -0700 (PDT) Date: Mon, 24 Aug 2026 00:00:50 -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: <6a8bec22.dbb3a75c.13dd47.0063.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(); }