Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp280461lqt; Thu, 6 Jun 2024 03:30:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcDzjMEdP7I0/DJbBtBwxM4l9RX2y2swakaiCFzHYN3xNPahTf6XNWEir5+BMLpaZ/7oWheP6YubK0Aw0goxUdW5+B7jM8Oycv4W+Q4Q== X-Google-Smtp-Source: AGHT+IFcOirrT/UZgMpeORz3ON8U1iTCKmwz9Nc9FbiVhrjF76j8L3O53BxrBJK/SrEEA3sgxaju X-Received: by 2002:a17:907:6d08:b0:a6a:ab5:6f27 with SMTP id a640c23a62f3a-a6a0ab579d8mr363850966b.8.1717669807569; Thu, 06 Jun 2024 03:30:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717669807; cv=pass; d=google.com; s=arc-20160816; b=hOfN+xok3v4ElognNWCvp9iv0N2h9a25H5Ya1xeo0t12pfqx1yVQPy00/a9s1cb+Ox Hah/WKW8YXQgXnFYvHEb8QnNjOVqUO0x7stgdgBejcDuHqGC9u3dvUSqmIwheE0VLh7K OMqBGoubUsjErw0UQQXFqsqNtnHjsBvce63202KmqjMzufaKEjlzW9zpuBvfDqGPW9+3 6o6VRgnyrmk4zrNnnuKshgP1xb6ORFp7UV/nmMMndbwUFfsbXUCGY2Zgx3YIu2ocGLOU 9KNMq8NLChvoZkKQbZvA6oKn0aquofvum0CgSiivAx1xO1GRtycjn6C2WLFcCmaAzxQD g3gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ggXsZ5O7EJdXexmykc1uJ6RGctKrzMdkn3uws89WvSY=; fh=AlvU7w2ixc9HVx2qhc7CIHNak4dJA4DXHrN3rrs52fU=; b=uckf5rbu7ctJ3nRDSuoOFEQEYOjEDkn3L7UFyOfTsvAbrlS7/20u6/8TejqxysZjGI 6SOnW5ML3ai4SBA9jn0uypthNe7WqXpgPo5gQY3n9T2ExZg8gaeBZWKCiywZ3YnDkfRT qbTATzl+ejg5OeRGss8CI2fixj4CFcRQXOSmEDjiu9/kUpzntpfXVIMhGtX4FoXIbZPk aPVLPnGy+bqlNSszKbFQDZbnWfJOcgZTkOq8PDkHczwQU2sc/xq+iDayP0qrmbQpMDUn Vue2r1RmxcaGNwuu05znEPX+Mi2oFkdTYDs/j/LHJc1aISas29Dzuvki+xvqTBT5uEfD rhcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k+xivNkp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204107-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204107-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c80708323si53481466b.601.2024.06.06.03.30.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 03:30:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204107-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k+xivNkp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204107-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204107-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4933E1F26B0A for ; Thu, 6 Jun 2024 10:30:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 943FC1953BF; Thu, 6 Jun 2024 10:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k+xivNkp" 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 BB6F2194C63; Thu, 6 Jun 2024 10:29:26 +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=1717669767; cv=none; b=G22WSGmrAuZy3Q8CU43aFYzhTonA7Fb+07qCdeWnZt31jLs9g8aPrTP+/il/Ax9OI5EKzY9QVxoMPPWvyZslEujeCAvBbb7WTztn9lHZ2tZpfiltIfJaYP6OWQCjpxkVzV6KR6uCZK5RfEqjaQyMhpGAor1u/Mfj20Ou1fxTDu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669767; c=relaxed/simple; bh=qhqknNWVMeNYoWtTdBFYEjniMNaEAVGn4mAJNY/G3To=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XHCcd+ZEpbZzSYD/fB1m/rkrI1q4YVLMWVckDGSf4mbC+USeZoX70vUeNNdx5WceKYbSzqCajDX7L8z7eK67tTVKETR6l642cYddtPmmMvV7FjXogbPK7nAVuUTF1eEv0Rrzx6K/iCWt/+hGGcpgP9TemoR6egkuJMIEQBBtmG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k+xivNkp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 877A6C4AF0F; Thu, 6 Jun 2024 10:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717669766; bh=qhqknNWVMeNYoWtTdBFYEjniMNaEAVGn4mAJNY/G3To=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k+xivNkpkyVhP1NuwNn+lsy8+20Ri42Il3zhipU1fxf8wo6vrLJp+Scs92UYJETMc yCkDwht9art5jJTfNiTyj48jjXCFnHkGKkItGnHHJQZVyLWmic+dv1hcIms34EnpPE e9aX73VH7w/YSpHPRVyk22wRauXo2Utv9OLK7svRtI9myoUyJQlJF0cXCT3T53Mn7t zWPFwtuz+tJDbwCPtb+fAkXgMsFK4D5BNENzFAgiaqQsSKXPXhbn+P8W60QYPaGImp gRYNGgW1qglssWl4XPG6ia0iOFkH3qY4FX1y0GJpTlREjlsIpQn5qxyqUzZvAo6Wbu 99yoYfX65B+Zw== Date: Thu, 6 Jun 2024 13:29:21 +0300 From: Leon Romanovsky To: Hillf Danton Cc: Tejun Heo , Peter Zijlstra , Lai Jiangshan , Zqiang , linux-kernel@vger.kernel.org, Gal Pressman , Tariq Toukan , RDMA mailing list Subject: Re: [PATCH -rc] workqueue: Reimplement UAF fix to avoid lockdep worning Message-ID: <20240606102921.GE13732@unreal> References: <4c4f1fb769a609a61010cb6d884ab2841ef716d3.1716885172.git.leon@kernel.org> <20240531034851.GF3884@unreal> <20240604105456.1668-1-hdanton@sina.com> <20240604113834.GO3884@unreal> <20240605111055.1843-1-hdanton@sina.com> <20240606073801.GA13732@unreal> 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: <20240606073801.GA13732@unreal> On Thu, Jun 06, 2024 at 10:38:01AM +0300, Leon Romanovsky wrote: > On Wed, Jun 05, 2024 at 07:10:55PM +0800, Hillf Danton wrote: > > On Tue, 4 Jun 2024 21:58:04 +0300 Leon Romanovsky > > > On Tue, Jun 04, 2024 at 06:30:49AM -1000, Tejun Heo wrote: > > > > On Tue, Jun 04, 2024 at 02:38:34PM +0300, Leon Romanovsky wrote: > > > > > Thanks, it is very rare situation where call to flush/drain queue > > > > > (in our case kthread_flush_worker) in the middle of the allocation > > > > > flow can be correct. I can't remember any such case. > > > > > > > > > > So even we don't fully understand the root cause, the reimplementation > > > > > is still valid and improves existing code. > > > > > > > > It's not valid. pwq release is async and while wq free in the error path > > > > isn't. The flush is there so that we finish the async part before > > > > synchronize error handling. The patch you posted will can lead to double > > > > free after a pwq allocation failure. We can make the error path synchronous > > > > but the pwq free path should be updated first so that it stays synchronous > > > > in the error path. Note that it *needs* to be asynchronous in non-error > > > > paths, so it's going to be a bit subtle one way or the other. > > > > > > But at that point, we didn't add newly created WQ to any list which will execute > > > that asynchronous release. Did I miss something? > > > > > Maybe it is more subtle than thought, but not difficult to make the wq > > allocation path sync. See if the patch could survive your test. > > Thanks, I started to run our tests with Dan's revert. > https://lore.kernel.org/all/171711745834.1628941.5259278474013108507.stgit@dwillia2-xfh.jf.intel.com/ > > As premature results, it fixed my lockdep warnings, but it will take time till I get full confidence. Don't series fixed reported issue. Thanks