Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792597279; b=cy787voAF0Q1HGrENteUT8tfqegEbWxEOQDJvTbMukgdjFSj6asoddDls7PC7TwGVi6k CWi6Er+qGGSRRnm1ydVbzbvLxCbfyoH7a7bLBvCNN+CK8/rPsU+RcFL6NIfWoq/g0PV3+ p8xqI2UJsWIGo2vy4u9fkrc5mdvFWRkAbzLA2gydVLYBYWGHpYkIfrgTvh3QQSx+gM8rN E9twpfMsg5hw4kueIwV7PFMPKbKsTmVd1ft5JzPjk+w07kJarGDG1r/HT4CKzzHYcJ8Ec Q7kjRgK8/1hTY29xQwYuL4KjkgAjVtnvBml7oFctWPRogplOgWApzEkG9K6hlA5ZoDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792597279; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=8cOsKnhmrfgxsQXSkKEorhaG1+R52K6stCjAb3LTakI=; b=PPZ1oEk0iXTRsw4PmkFRslJbKOL6+CggMZ88RnNjvhEyEL8fftyweK6uFUjIsG8e27t0 5eklNZKYPxkUkT1aHzW33JB/k9TMcAOmcuahZxRGrOnATXtHSBsuL3LQDYOAceUk2SlxA 4x1WE/GkaT9DoVlogWDk5dTXZ4+miFmo7qUBFIYS4JIkrwdzTrsKXCTQTtfhvVXw76wKq 7KMoGD7wpc+uWaAaVnw//ptFXlocJfIXJDRiLmyRg+/EYIsiK7sBP+uG9o0fd53JMTGrP SDCr8DDGTfA6Dc3hbZY31IXfTMblhFGJBUpMc1DYxFiMYZ8XRY6tAhXJhubpww++yiw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0v0zE0io; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F283606A31A for ; Wed, 21 Oct 2026 15:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0v0zE0io Received: by smtp.kernel.org (Postfix) with ESMTPSA id B28AD1F000C1; Wed, 21 Oct 2026 15:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792597279; bh=8cOsKnhmrfgxsQXSkKEorhaG1+R52K6stCjAb3LTakI=; h=Subject:To:Cc:From:Date; b=0v0zE0ioYI6zOM5wM0ON8Glm4p9of0abM+hNa44gkwAcGSXC450g32eQXo86ueKIJ dtzr//ctsyn3G4X0KvCOfywxnlItYtY9nFcI8r6VgQwj1uvRnLCTZ211hNNajnOLM1 HiorwnKE4LVA6WB7LOnrPBOhJdqRFJ4Q43tWrdU4= Subject: FAILED: patch "[PATCH] workqueue: Fix unbound pool lifetime for pending pwqs" failed to apply to 6.18-stable tree To: yaokai34@huawei.com,tj@kernel.org Cc: From: Date: Wed, 21 Oct 2026 17:35:48 +0200 Message-ID: <2026102148-outpour-epilogue-a40f@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x cf9c8aaea0d47410df8708bec195889f3a85cd3c # git commit -s git send-email --to '' --in-reply-to '2026102148-outpour-epilogue-a40f@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From cf9c8aaea0d47410df8708bec195889f3a85cd3c Mon Sep 17 00:00:00 2001 From: Yao Kai Date: Mon, 24 Aug 2026 11:58:52 +0800 Subject: [PATCH] workqueue: Fix unbound pool lifetime for pending pwqs KASAN reports a use-after-free of an unbound worker_pool in node_activate_pending_pwq(): BUG: KASAN: slab-use-after-free in _raw_spin_trylock+0x6d/0x120 Read of size 4 at addr ffff8880089ce000 by task kworker/u22:0/318 CPU: 1 UID: 0 PID: 318 Comm: kworker/u22:0 Not tainted 7.2.0 #1 PREEMPT(lazy) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Workqueue: 0x0 (flush-8:0) Call Trace: dump_stack_lvl+0x53/0x70 print_report+0xce/0x610 kasan_report+0xce/0x100 _raw_spin_trylock+0x6d/0x120 pwq_dec_nr_in_flight+0x4b4/0xcb0 process_one_work+0x921/0x11a0 worker_thread+0x4d0/0xd20 kthread+0x2de/0x3c0 ret_from_fork+0x3aa/0x620 ret_from_fork_asm+0x1a/0x30 Allocated by task 311: alloc_pwq+0x439/0xca0 apply_wqattrs_prepare+0x75e/0xd10 apply_workqueue_attrs_locked+0x44/0xa0 wq_nice_store+0x350/0x450 Freed by task 0: kfree+0x127/0x3b0 rcu_core+0x523/0x1780 handle_softirqs+0x1b3/0x610 Last potentially related work creation: put_unbound_pool+0x3f3/0x7d0 pwq_release_workfn+0x494/0x8e0 kthread_worker_fn+0x1ff/0x790 Canceling the last inactive work skips pwq_dec_nr_active(), so an empty pwq can remain on pending_pwqs when its refcnt reaches zero. pwq_release_workfn() currently puts the pool before removing that pwq. If this drops the last pool reference, the pool can be RCU-freed while the pwq remains reachable, and node_activate_pending_pwq() may trylock the freed pool->lock. Remove the pwq from pending_pwqs before putting the pool. Fixes: 5797b1c18919 ("workqueue: Implement system-wide nr_active enforcement for unbound workqueues") Cc: stable@vger.kernel.org Signed-off-by: Yao Kai Signed-off-by: Tejun Heo diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f2aed36cf7c0..0ee73dcd4a14 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5294,12 +5294,6 @@ static void pwq_release_workfn(struct kthread_work *work) mutex_unlock(&wq->mutex); } - if (!is_percpu_pool(pool)) { - mutex_lock(&wq_pool_mutex); - put_unbound_pool(pool); - mutex_unlock(&wq_pool_mutex); - } - if (!list_empty(&pwq->pending_node)) { struct wq_node_nr_active *nna = wq_node_nr_active(pwq->wq, pwq->pool->node); @@ -5309,6 +5303,12 @@ static void pwq_release_workfn(struct kthread_work *work) raw_spin_unlock_irq(&nna->lock); } + if (!is_percpu_pool(pool)) { + mutex_lock(&wq_pool_mutex); + put_unbound_pool(pool); + mutex_unlock(&wq_pool_mutex); + } + kfree_rcu(pwq, rcu); /*