From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (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 E4BE420ED for ; Sun, 23 Aug 2026 21:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787522057; cv=none; b=m9OWuRxM7eUX7+T/HZt1+i7hiIkHeBSxPMvBoDWG2JfaxKXsCsv010rZ+u523yWjjVSo3bSWwdTNrJpV7AuzTTofPwB70SBdndTLKS3pFDNyIouCY84gkzDZxm5B9L6nxnRyF96vHis05vggBxWspfqu4jinPVwOHqAwxYSNy2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787522057; c=relaxed/simple; bh=awq8wNj7lFxj62/M4buU21bzu0PJrZSrG/rdgNojwrM=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=cnmZRqext5GzMSG7l/7UeW5YlO8ytAXNQAwGPFhKYykXxVpmmleGDG35LTy9TwLMzhkm9hoPV6scuayoRrrQfiqIhL+hUHE1T13s/M5IxFJQ7lR2cONOFck+1E6VC7lMcA5V4SIz3iUcqTYs0IUkpx6ffnPcgdKWBSDyhyZYsmU= 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.198 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-f198.google.com with SMTP id 5614622812f47-4b28dbf4197so5775142b6e.2 for ; Sun, 23 Aug 2026 14:54:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787522054; x=1788126854; 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=sG2uykgP0Z4pe7bFmW3GQYsuPdT4mt+xhhLsJBZAYjU=; b=rydkhttIUjQNONp6AN50YN8MXsavKkHnlE7BDe4j4/Me2FHlDRcjQY9dUhFu9Wczx6 P249LgCl0UQa/ae8VQ+wAt9k3rYdIpxb6VRAVUQD+72DO7SG21oKsHcumYyPr78q6Ml6 l21SnngaiC47lLn+jOeLQZAqTYxTdY7KIEeVoTvDE5gsP9A2ZhXqu4jDdHgQqhDRHvKw UwwFBUeK8rG9CUI/cPZzrHKp6fTWSMccJVL3Bt1CQcinRGiLUfDzX3Oi9VYEezAEYFOK u+8qm2S5JSjSzy6/hIVqoM/IIwYrBRilQ2MfIXN08RV6IZzFVBeG8M0kiAIEojWDIPLi mv+Q== X-Gm-Message-State: AFuF++nhqLbb2955f9R+sJjHOIlW6y1HKTyy73eo0t6xn59pXXMU+Eog d1zRWgdcYWgWUX+F/bVx1o0kArb1dX0zf8SD9kcpH/1mSp2okymcc/aLWq3Ik/HzuxRUGfxl8ed jiiMQRjvFflb2W/kZHqeQVX8HQFnSn2bK92sfe+PMHn0JzHvxJ2EqepZrhY4= 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:f92:b0:4ab:3210:b31a with SMTP id 5614622812f47-4b2ef3c6094mr19343710b6e.14.1787522054551; Sun, 23 Aug 2026 14:54:14 -0700 (PDT) Date: Sun, 23 Aug 2026 14:54:14 -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: <6a8b6c06.ae6ddae5.3da009.006c.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 Please test the following patch on the upstream tree. --- 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(); }