Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp307913lqb; Tue, 4 Jun 2024 11:58:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/FFyaD0aYvQwGWUzmjttE6LcklwDxOpE5imooa9n6J8oTLCimQ4LR5fPAMPQNW1mFU/o5TRAhh28ISPGl9m06AYSHRYQp4kfB5VNBSw== X-Google-Smtp-Source: AGHT+IFN3cAcxmWsQ7KoeqMp/VihgTV7nvyurwUlHZJNaakB7VJZUXael0NO15LTGd9i71fMKtW0 X-Received: by 2002:a17:907:7426:b0:a65:ab25:24da with SMTP id a640c23a62f3a-a699face4e0mr20728466b.22.1717527516105; Tue, 04 Jun 2024 11:58:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717527516; cv=pass; d=google.com; s=arc-20160816; b=hUcfsc5hOpKp3tc78MnCPMkiQFK3TE3DgcloIs/lIi3z0++k4AnaWPno475kzBQc1/ RtMXYrfHiIQsdA1zt6GfRxkOA/XeWR181nfPNiwSfAcY8fsfXZFaMPfKhCMxWgKkQABo FSa9yRbv3P2+YDDXFMynTZpca69ZWyTdcdRwIlZzWKjwDbs2H/AcLUnVS7Oktw6p52x7 cFcVVX4zpqKWfXUn+yPq71IQPxEzoQirIH9nyCFFmrW30eJ+OGVfyffUy7/k68HvEZSF FRi+HoQz0KJgSE3Sg9SrXBcejOOCZxhFJN/N8GbNrL8GS+FLN3nMvgZaHaWmf4pMFcYl 7dGA== 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=1uKA0WsCMYBWjo8mUTm5/OO7N4Sq0attCBCoQ+2PlLE=; fh=fRx0Un74+FI2CixYTSM4xnHJ6AmwCYvORVBduWxCOEc=; b=JiOClhm8RYZyvnPakxgyiNxr1QIvyRD8XrCHN78+MLz4jRBfKGcbwaZXp0SrTPfFg5 jXILreQIoolW7mANaOxyftCMV96PQO3HAfes1CKYQWjEWBf+jaQQp9jYW+hhNYBUO7i+ +ltKqKNd/P/gLAfC0QWmjy6vPXcMb0pmfuL4avSJXYC/y3nVyrYfye5l9NyIZMepuAnX mBVsVSZllFAqBs7vbK6AkI4PaPAF4XeJ19rrHm6Ep+RHw1P+jlIZZx2ki9rlV5kQeZEk qV+HNVgLQBQJJm15Q2iKI20wqLYcWMmcVjhVlE5yKiBobrDBKWnS6c7ZNxUylNATjKAQ v5qw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aUdLj4Md; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201263-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-a67e74f08f1si523814466b.250.2024.06.04.11.58.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 11:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201263-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=aUdLj4Md; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201263-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 F1D361F26C35 for ; Tue, 4 Jun 2024 18:58:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9308E14A62F; Tue, 4 Jun 2024 18:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aUdLj4Md" 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 BB3134A11; Tue, 4 Jun 2024 18:58:09 +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=1717527489; cv=none; b=XIieI9XOQd7xd7ICEfcYOKutYCUqrl/FADH3CpAeO9xT+Ur/cJaU1qWP0hGs18HdokO7d5cHZHwPUXtLr9FyQE34UarniQX/u+4d1ZGvaEA9rc8R/HziP5big5OSk2CPD+5jWQYfVr5/Q7RbaZmwFnb0EeDxwQVrAinHFZ/B4h8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717527489; c=relaxed/simple; bh=7nozJoS27TnUtwEyt01rUHz8ZytmR7cN5oUHgzupIyw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ckdo4ZD+U5vWfA8kuFB7A2sNJm2pvIqWN3DF6npTZYqacvFZeiv9kIRoVTJ3+SsuR3XtoBxyzM0mcR2LRKtzTnx/0iAbjRYIaOoFw5INvG/nlfyzvGNP0nStoRhQFz4iufA19+Sg94Zq8qzoW58p4oHByQHrfnwmeebb9Ea+SBI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aUdLj4Md; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDD2FC2BBFC; Tue, 4 Jun 2024 18:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717527489; bh=7nozJoS27TnUtwEyt01rUHz8ZytmR7cN5oUHgzupIyw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aUdLj4Mdi847j2rt8G31dUu+LngXPIo5Y7OfpGAHnqACt9pfar2v9fejJjW5UR9j5 98hh6DW1U8Ds80qB9ufxDNw1lpZR5wAnBuvgAnfedHPD+Jqq9MZNUBXfGPhmPyYVdw cHhxnGLCEkPBG0i9k1Z+QIfQZU6g2iltouQZVtgMqkwNtHgoTEqZ/Nc6Pb6uis2oIb 08ea49kKVVKyZb8Aeypgo0C1JO/+VCSZK+3Bzj8oxiDUX2+d2Ye/egolK3mAfrv4CF JsrEKF1ooBTgvbMshG9MlExosHPcytMxoHOcNpnkWfYzoFZyA7jFFLR5Qgy7UrUTOr Ec1wDVb88BNqA== Date: Tue, 4 Jun 2024 21:58:04 +0300 From: Leon Romanovsky To: Tejun Heo Cc: Hillf Danton , 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: <20240604185804.GT3884@unreal> References: <4c4f1fb769a609a61010cb6d884ab2841ef716d3.1716885172.git.leon@kernel.org> <20240531034851.GF3884@unreal> <20240604105456.1668-1-hdanton@sina.com> <20240604113834.GO3884@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: On Tue, Jun 04, 2024 at 06:30:49AM -1000, Tejun Heo wrote: > Hello, Leon. > > 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? Anyway, I understand that the lockdep_register_key() corruption comes from something else. Do you have any idea what can cause it? How can we help debug this issue? Thanks > > Thanks. > > -- > tejun >