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 0126335976 for ; Fri, 24 Jan 2025 19:30: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=1737747026; cv=none; b=RplhXYtZl4rurPnLUbfph7fygIbtk27RQM1z2sz8tAp19YUNoPJJd846iHz2yJ2jTOU6XJ0DVW9n5Nkqk4XW2PBjWgEVxsUMk+LKwwYPu6/Wa/3x/Zm8lTLWlHzJOLOyx+FwSTuSAZkNjetVtFrBfaBEp/FyuhwcDsVgGNzr+6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737747026; c=relaxed/simple; bh=mxkMK0sYGIgSh7l4vCjWLcpgzvORFydSwPxsJVGzn6Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GYHROqCB8LvLqYpxqGOayZJl9DS6cv07mGhGs9Bt6eRGaYn+Lg16ihKwGnqf8hw+6Mi96U7OlaJ4x66InTSHbUqD8lLCwBpKOTxKmVI7NcDil6iAW8wJY7T5rXLi5j6v7HWT3iJVCxzEffZbAHQKn6XZaiPgaLLMtqPbGCT0NiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QDkf9POh; 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="QDkf9POh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 407CAC4CEE1; Fri, 24 Jan 2025 19:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737747025; bh=mxkMK0sYGIgSh7l4vCjWLcpgzvORFydSwPxsJVGzn6Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QDkf9POhNTuMmsEj7xf0z6Z3z0UHit5ckSwwgIDuBLzrRMuEmWg6KT4FQ1Wvq1LBB X8qcts6v0Y56us+FUyAigysSV5ajjMqqRuXL8q5gA/7QLC5YkebiUSxWDf3dpfiE5h hWA4nTMlv94o78bdniFvyeljoTDWdQx+gCeBijCsJ2FaijkhOAuDbNj6T27rULCJmN rEF0NBlWaN9Iivypbq4g8T4dD5C8JiUTtIKEMFDzM10WVxiAq5PXFBaGoTdWmeAx8D QMA913VlhUq2ymMXjr4nALNuyYxTkxN07AxBNvxt3D5x/sQD766GIOcvdnSp1UPPDx Q6/O0zXCFc5eQ== Date: Fri, 24 Jan 2025 09:30:24 -1000 From: Tejun Heo To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , cheung wall Subject: Re: [PATCH] workqueue: Put the pwq after detaching the rescuer from the pool Message-ID: References: <20250123082535.1538074-1-jiangshanlai@gmail.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250123082535.1538074-1-jiangshanlai@gmail.com> On Thu, Jan 23, 2025 at 04:25:35PM +0800, Lai Jiangshan wrote: > From: Lai Jiangshan > > The commit 68f83057b913("workqueue: Reap workers via kthread_stop() and > remove detach_completion") adds code to reap the normal workers but > mistakenly does not handle the rescuer and also removes the code waiting > for the rescuer in put_unbound_pool(), which caused a use-after-free bug > reported by Cheung Wall. > > To avoid the use-after-free bug, the pool’s reference must be held until > the detachment is complete. Therefore, move the code that puts the pwq > after detaching the rescuer from the pool. > > Reported-by: cheung wall > Cc: cheung wall > Link: https://lore.kernel.org/lkml/CAKHoSAvP3iQW+GwmKzWjEAOoPvzeWeoMO0Gz7Pp3_4kxt-RMoA@mail.gmail.com/ > Fixes: 68f83057b913("workqueue: Reap workers via kthread_stop() and remove detach_completion") > Signed-off-by: Lai Jiangshan Applied to wq/for-6.14-fixes. Thanks. -- tejun