Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp226315lqb; Tue, 4 Jun 2024 09:31:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfs6K78IEbWKTq8pyKu5yWy4lANTTAfH9KQK6+gSuW9l8rxM6Q69Z/uSewpeyv95+isULDXAadiRJWXaZ8c8gpOkAt8M8vRpDaQGze/g== X-Google-Smtp-Source: AGHT+IGT2NteytFyfDYyupyygu2j0aXbUTGSwaabNyiR7UWSWbQBWDdGukp63uJnumW88Uzb7z4e X-Received: by 2002:a05:622a:391:b0:436:5951:6006 with SMTP id d75a77b69052e-43ff54fa75bmr176532251cf.49.1717518662014; Tue, 04 Jun 2024 09:31:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717518661; cv=pass; d=google.com; s=arc-20160816; b=CWe9VrheECl18+VZVsvOwTlayKtup7mCWWa7jnSIxMhvVv+0tEapXFWsJrSGx/YVEV pUfUi2sDZ3MGGImhqHHnApyoUX19oFX7DnEME1EnWV2MgWkcLpJ1o9TtnVeTETpTts9q LPA2e3xWV5r/zj7o4RtrmCxtNsgLNjOgpW99/7S7l4AlJt6DBcTd/kdISvTM64o9ehD8 HP83/U85XUSgIEgRyUJmWMRdwTRP3lViB1QJVYkiJh+GEbSvBOE5SaHWfC8SHlXwBdA9 jjVJ81+1a2rujeUcdpgiG3VopU96aO2ZIl6V/gzjX7R0K56J8QGGlRDCbUrsvm3ZJ+Pt MzGA== 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:sender:dkim-signature; bh=83p7cdIpWkem+14akSHUhV9KHZt6lrNKJIFaFfNsCQ8=; fh=0FH5xW+DkgBee7fdZ02L0foa6nc4cdzt+Eejhhy5Sls=; b=R8IFXAKLuCHY0t9e5Lc+rU52jYXxq2AJNDT6+fWKWZzwTRkBlDU5t+xPQoDe3FaF/6 u2UHvYS/8g4x98+lhfhcgQgNrTjuDMeAy8vmn/BCxAy0ZloBc2jfkPqn47dNqdUgctaU FyU8OnuLPuv8kiWtoPo5ztLSanIT0n1ZknqLgXlmhytq3EbcarUJOmg1xmEtl1JOhFkk r5KgWRLfmDW+T85ZQzx5DFTPcxyN6qXQWPrKEdtYnVhEDpkSN+J5dbjLQsDzA079FZ1b cBTw4+XSUEBgYJPECXr8jFWp5cjFFingfGY9a6kDgawEyB6uy7dbEQ/LWAtQZpNAPIbU oGDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fkzPk0Mk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-440270ccddfsi10133771cf.70.2024.06.04.09.31.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 09:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fkzPk0Mk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201075-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B57201C22083 for ; Tue, 4 Jun 2024 16:31:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3C5C1487C9; Tue, 4 Jun 2024 16:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fkzPk0Mk" Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C15936BFC7; Tue, 4 Jun 2024 16:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717518653; cv=none; b=aH2yF+pm6NQHKvDaTIfSVkAspeoyEv4SLbAxRRCQoZzHNUWDDLH5jsON8gm9DFQT/Vtpe1/kPVCfSrhCLC30g1y6cEMsjFGWjljDrMMO4Y/cu2i5qmAAVlxar31stJgMmW4N5wh6wlksArhnh9+TA0v7C3iZB69B8VuOYDv3Jxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717518653; c=relaxed/simple; bh=g2nNoE/jBPYFHGgG9KjF1D6qbp8g+/CUpdddbyNM52A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t+NvyQYtq9oAWC9Wpi06AdX/Ektlz+0gTv4hZXRHBp/ouLU4fy4fIHPObSG0EcuqyZw8l5tIE/Cmc+H7Vu3ApjZncHXEl3iX2Ub8Hf76D2v8qjBap+JQmB2DlUwUTTf1TYJyGhMVGlIc5DCtI9HH0IL9xt1Gk3ICXney5kX0P0o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fkzPk0Mk; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-656d8b346d2so4155053a12.2; Tue, 04 Jun 2024 09:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717518651; x=1718123451; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=83p7cdIpWkem+14akSHUhV9KHZt6lrNKJIFaFfNsCQ8=; b=fkzPk0MkIfdJBKQ/4xyl+35Sv0S+Ji/9NeTx5BqhMvMB4P8/duH22kbxxAkYmm4uWQ ik6h4XIOIjiihPvGiKMNr7slKsCLUR0cRbcU93zmgX5WJwmLlbyvx1kG5d3xgtH4uNq6 QNC2dVTQdllpnxh80lLyoPb+mdDRz8ThXz9UsHX7M8Cp9zZ3zJsHBzozgmwLKwxPl7Ez /3HwVqpfM8Nfeu8HfqCe4OoXegTxfMJDbe6rcOQ84FAhXSuOMW/CCG9ImxHc6RwVyEyD WHzZ3Bxa7wtN8elDaHi2CmZdftldomox9RKi/6IW46JOjp5eILFw2Unu1lbRmXIcka/R pZ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717518651; x=1718123451; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=83p7cdIpWkem+14akSHUhV9KHZt6lrNKJIFaFfNsCQ8=; b=wnLh/iOwsRC80BoNK1D3nJTwHGgih8Cso6gV3ZQcndf5EClhjfkFsjrXETQKO6QVUh QmUm7MkWqn/toYK+XFdAFwE4j8KQ86tVWI/nbd+NR6RgjvIFgD6mANS3xRAbqJqp5dhx ZLOz4Y6JrttWmn+M7xA1DMrrsG2nihIWGgtXSbX1bw+Kip4HxzDqDJXfn0oQHUp/dVNR AYYA8ZdmdVWfAUBRPb7bytHycAwxJZ+YLraxRSHE1QWRddGsz5hP2GEbyjXORWSyIjMA tVjmV5l2XBA0RUedFabI7slpxr+hgYPHiIRvg8ZSexsWo2sxz3SYTwqj4i2NRSgcKWK6 Irdw== X-Forwarded-Encrypted: i=1; AJvYcCVpQRb6XUJTg0rLDcU1mBFZ3ef8SaFMrFH9wtsblnRlUkzcXLo3SFnAiy9VXuHUrlhTEruOHgtUvW2gQWfXwMP9BfIVW441ywKgP5E4IsncQ5BQE5ceji7KudSYpCc+hwnWQBGx5lXutw== X-Gm-Message-State: AOJu0Yz3ivJHySsOLAz1TqqAWRgE6RWnsHbHfz6vei9Euo1SbdI/sY/+ DD9toCRlqfOWhmQqidNLGsRI9aoDXgbZIgfFxuKlMvTwsCOyHdWF X-Received: by 2002:a05:6a20:7289:b0:1af:d51a:1ba9 with SMTP id adf61e73a8af0-1b2b6ecaff2mr204228637.3.1717518650902; Tue, 04 Jun 2024 09:30:50 -0700 (PDT) Received: from localhost (dhcp-141-239-159-203.hawaiiantel.net. [141.239.159.203]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6c37e984267sm7122382a12.42.2024.06.04.09.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 09:30:50 -0700 (PDT) Sender: Tejun Heo Date: Tue, 4 Jun 2024 06:30:49 -1000 From: Tejun Heo To: Leon Romanovsky 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: 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: <20240604113834.GO3884@unreal> 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. Thanks. -- tejun