Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp2381403rbb; Tue, 4 Jun 2024 03:55:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfAEKW04qEabMojVaNvKEFzCWeWqtXU6n9c1s12e+o9DX8oohPD1h54edj2RlyFXGFwIT4P5Cc2SJlsAhryoa4IG8a/1jCcDWjmw+dxw== X-Google-Smtp-Source: AGHT+IFuaMPPzuxa+n0jl33QwptLtjYVKliIVJhDLd1LX2FVXgyW+2FlQECVxOkAxtOjBt7ckmCm X-Received: by 2002:a05:6358:3120:b0:199:3005:1a6d with SMTP id e5c5f4694b2df-19b48d4ec5cmr1378321055d.5.1717498535155; Tue, 04 Jun 2024 03:55:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717498535; cv=pass; d=google.com; s=arc-20160816; b=Gtgy3lUB0LmzVZYkw8s+ZYAMhqFKF5sT5F3cyger5a1W3WX2bSHmqNb9Zk1DBUiPxP M6d2r4JD4r7MHWmzVbeHJtMtuNgQ/X4tXvbYFrJ4PkLr7FNdmu9u/gZlcXBWsOyvOptn nZMIqjeWPY72RWISIa7Hoo0DwViVozRcobmBdTHOj9oFHBpitaQvu8ic9T3+9T6DWl2L MoAoCD4Bke0XNvxG/WzrMgq8kvMsrr0zZojNcFsT0sT8htBxwpaOV/av4HIkSsQw98tM VRsMqUnN6na7N1RBmsZhoAHOic6dwXEdfw9HoHtXy/WTrBiCrtPmdC70V7I4WqXFJcwP moRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=t8c25wwGYE0ga31FZ/PZ1X2wdRngvatYBMKQlwdcnxw=; fh=GNljk6khYw2LmrHUooY0c0Q72ufUafnfBMAImDYaMuc=; b=qP3OM2cZizqEWpjtSgElWnbFQfLjxF7vTA82pkGveWk1NGkWy4vXRT4c1v7BvCkHuK mrZ/XnfDTVCfsmfEkkpv/aYSPEVHfwVNkiKzHcdZH4IvgeG33i2eZCv6v3CWD9rDEoZP PoEmWXYDT9E1f/GuxzBK8K4poX31RmgsTeNSJCouFc9YPbVWaC/KEMmi4D7Rf8nBB5Kb 41Ag2BZZnUlyP+H9xGfHLxZ7VW3AwRlsUdZDMSkmn9ZeS4qNWfnOxMSSz06+zbaEbZ1+ y+lY7S5Q3HrzdORNgEsDRR842NdAMN4Ev8No9L3xH+Dxotg8BAFZzP66jzTnuG6AMjfB 0KRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-200476-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200476-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6d31987e4b7si1049390a12.881.2024.06.04.03.55.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 03:55:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200476-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-200476-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200476-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B611B282D92 for ; Tue, 4 Jun 2024 10:55:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61403145341; Tue, 4 Jun 2024 10:55:27 +0000 (UTC) Received: from smtp134-31.sina.com.cn (smtp134-31.sina.com.cn [180.149.134.31]) (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 B9D79144D00 for ; Tue, 4 Jun 2024 10:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.31 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717498526; cv=none; b=fRVhpX5uPZWJ0F2otRfCen4OEgMubpZsU856g4v+3KpQyckiaBQBaLsvNCNz+lEFKV/WbMVBGrSSHYWxwYHvL19AUjfgi4CAVL6z3IU2oEpH1tWwQQYaJtk17Vr7LJgHyyc/6qf82I1HBdaOLrUC6/LMhwDgUQX2G1gSgr9Tlxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717498526; c=relaxed/simple; bh=wV5Cq68GjGdP5oijvBuOZFA7zgkjpyxF8ip/BZcMOw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r0lECyVWShMx1aqqcf2+an49dNc6aMWjf4XR2kb8kXJgSphGRBPGGSx3qMNLqjs2cRzonW8ViqZaInbQFJ1y+Ls9AwmqClsvlwZ7v/qTYBpVvDHxS5kx3ivVTusw+P54Bn+AKk/0HLTQ4Xb2g9H6HWkVSMqeYg3HNsX0o3+isF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=180.149.134.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.69.129]) by sina.com (10.185.250.21) with ESMTP id 665EF28900003DE7; Tue, 4 Jun 2024 18:55:08 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 3986503408482 X-SMAIL-UIID: 0DC135B6AE7141AE9B325C5C6B26B03A-20240604-185508-1 From: Hillf Danton To: Leon Romanovsky 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 Date: Tue, 4 Jun 2024 18:54:56 +0800 Message-Id: <20240604105456.1668-1-hdanton@sina.com> In-Reply-To: <20240604080958.GL3884@unreal> References: <4c4f1fb769a609a61010cb6d884ab2841ef716d3.1716885172.git.leon@kernel.org> <20240531034851.GF3884@unreal> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 4 Jun 2024 11:09:58 +0300 Leon Romanovsky > On Mon, Jun 03, 2024 at 10:10:36AM -1000, Tejun Heo wrote: > > > > And KASAN is reporting use-after-free on a completely unrelated VFS object. > > I can't tell for sure from the logs alone but lockdep_register_key() > > iterates entries in the hashtable trying to find whether the key is a > > duplicate and it could be that that walk is triggering the use-after-free > > warning. If so, it doesn't really have much to do with workqueue. The > > corruption happened elsewhere and workqueue just happens to traverse the > > hashtable afterwards. > > The problem is that revert of commit 643445531829 > ("workqueue: Fix UAF report by KASAN in pwq_release_workfn()") > fixed these use-after-free reports. > Given revert makes sense, if (alloc_and_link_pwqs(wq) < 0) goto err_unreg_lockdep; err_unreg_lockdep: wq_unregister_lockdep(wq); wq_free_lockdep(wq); err_free_wq: free_workqueue_attrs(wq->unbound_attrs); kfree(wq); <-- freed return NULL; the difference 643445531829 makes is double free. alloc_and_link_pwqs(struct workqueue_struct *wq) if (ret) kthread_flush_worker(pwq_release_worker); pwq_release_workfn() if (is_last) { wq_unregister_lockdep(wq); call_rcu(&wq->rcu, rcu_free_wq); <-- freed again }