From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44B15216399 for ; Wed, 22 Jan 2025 19:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737575246; cv=none; b=KiC+pLmiwzTRWKXGPMxZDIXCc/dwO814Asvuy+VL5TLHGkZFYkHD/UsL5/Z37zf2K6vcAgZ/eH1oX7eiPs5CDHdkz49i/eLP26mJiPyCrTe1jrpRzAE64lEcBgAa08eulOlb/mQp18jb2pIiSMXv5bGeF88RHN8/MobCssBLqFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737575246; c=relaxed/simple; bh=96gYFTk4l2fYE5rdiVqK4mdoYIIJlHziUiH+5QJhbfU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=twbRfpPv1XYPXh7RlurIFCWBuEdvpRgMWoOEsmLWN6f6IWzOh5ME+IyAd/CO0tNvFJhFlF2qSak7is/rlbE3RT34Fwk3bYXTGV94NhYmtalAzhOuzIGmJM8rxOxMN74dk6yThirMZQCAGDq7tip+Qi+Vie6giz7LXtZsAQkVp2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mZPuUjQ8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mZPuUjQ8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1E3AC4CED2; Wed, 22 Jan 2025 19:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737575245; bh=96gYFTk4l2fYE5rdiVqK4mdoYIIJlHziUiH+5QJhbfU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mZPuUjQ8XIcfwaPTnUizHFIj1r4ywHaZnbUsQXMx/ARBUFhmYNaD4YRL7MX7aA5as e612rLT8js3muziydnK5hACJAxNw5PNpCaB1sXbSY9WqsP44wCd3hVpgmfH/vjM9wb 2yRWj4r6HQry30mq9Gb+mriInTpb1VDOptizuG+SngBukanjOb8sxVxBlaxUYLFh9M gliKY8Z3auIFVAZGhT/Ux1N4K843LYm2YpzeILIDeWo7l3imL1gUvUXqyhZWZd67L7 m2T3Se7sCdtOyUWvbncWqHPRK2Nd+rs18qSesVqmO7iRjubJjoBNmEVLXTnwiGgtJP lm9DTeeVpQgRw== Date: Wed, 22 Jan 2025 09:47:24 -1000 From: Tejun Heo To: cheung wall Cc: Lai Jiangshan , linux-kernel@vger.kernel.org Subject: Re: "KASAN: slab-use-after-free Write in detach_worker" in Linux Kernel v6.12-rc4 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 15, 2025 at 10:10:26AM +0800, cheung wall wrote: > Hello, > > I am writing to report a potential vulnerability identified in the > Linux Kernel version v6.12-rc4. This vulnerability was discovered > while I was testing the kernel. > > Linux Kernel Repository Git Commit: > 42f7652d3eb527d03665b09edac47f85fb600924 (tag: v6.12-rc4) > > Bug Location: detach_worker+0x164/0x180 kernel/workqueue.c:2709 > > Attached is the bug log file and report file. > > Thank you for your time and attention. I don't know how reproducible the problem is but can you please see whether the followign patch resolves the issue? Thanks. diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 33a23c7b2274..e1d2f8bf28d7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3516,22 +3516,22 @@ static int rescuer_thread(void *__rescuer) } } - /* - * Put the reference grabbed by send_mayday(). @pool won't - * go away while we're still attached to it. - */ - put_pwq(pwq); - /* * Leave this pool. Notify regular workers; otherwise, we end up * with 0 concurrency and stalling the execution. */ kick_pool(pool); - raw_spin_unlock_irq(&pool->lock); - worker_detach_from_pool(rescuer); + /* + * Put the reference grabbed by send_mayday(). This must come + * after the final access of the pool. + */ + raw_spin_lock_irq(&pool->lock); + put_pwq(pwq); + raw_spin_unlock_irq(&pool->lock); + raw_spin_lock_irq(&wq_mayday_lock); }