Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp426336pxu; Thu, 7 Jan 2021 08:23:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqfOE5irWOQMWHGBJl9BoaMLL5RqMDBHIefShGkCVeCyroLnwzHLGNZ2yaH/oZ5xIiSenb X-Received: by 2002:a05:6402:22ea:: with SMTP id dn10mr2179417edb.67.1610036626930; Thu, 07 Jan 2021 08:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610036626; cv=none; d=google.com; s=arc-20160816; b=RajXWprR5aDtJUTVRwWEnOOZn+LFIXUXYRd0ariyLvySsXJ9MOQ7nZa+GS4ZC+/JEP FgmVtfQSnpZZIz8su2PI1YX2IdBT3wWTiw5bT/EIFxwpRyR/cAYNOf9py1rvlhJetatD HETXa5x3Ld6NDrt94EtjJyEsUG0pdllgnpJz5tSFgAsJejbUiLnqyw3UIB0+TMSCXu1H dOPhuoW2XUIt6bQj5oT1mR8MR/MmTlgmHX5m/xNlp354nebKk95Q/WvLQrdNgd2seNaM VDTY9vvKcTWVjokYWwuQA+19Yml5G9DN92ERwb2xYlBKzWFbYSU0hBShNujDGAQIs9yv +dRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=TtwrEFvP7xZrdSJEPw5WkuFjfwVEg/qN0LFtr+WYGnc=; b=BOGBozikVUT5/76v8PajiU1lpHKx3waSt4atDDRbv/7xYCnaPmatJgZ79WACiOKgQA t226uRvmYQbiMgLQiQcAJtO+uHzsLNLhjHK+rbc0kZ+59Glfu4h/7y7sywoAXKwgvNvv CHX8toJFHrRMft0+Kwv8ODtquM2hy20NfEIOq7bMwPuS55amy2e+YA+6FJ6BRxHiU97e /1qMHK1PxdtXg2+D56xW9CwfFXzWuJCXdyxHiDmi3982WFvhHXVEDw2DXJANClbB6LGv B2An+gzQ6phP8mpU5e+yDZMq9uLDYlwgfq9i7lFU7q0UkVxfnrnm55Hp3r/SQg7FrScn 4g4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si2400053edh.496.2021.01.07.08.23.21; Thu, 07 Jan 2021 08:23:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728401AbhAGQWZ (ORCPT + 99 others); Thu, 7 Jan 2021 11:22:25 -0500 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:51665 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728331AbhAGQWZ (ORCPT ); Thu, 7 Jan 2021 11:22:25 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0UL.6OEC_1610036498; Received: from IT-C02W23QPG8WN.local(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0UL.6OEC_1610036498) by smtp.aliyun-inc.com(127.0.0.1); Fri, 08 Jan 2021 00:21:38 +0800 Subject: Re: [PATCH v2 4.9 00/10] fix a race in release_task when flushing the dentry To: Greg Kroah-Hartman Cc: Sasha Levin , Xunlei Pang , linux-kernel@vger.kernel.org References: <20210107075222.62623-1-wenyang@linux.alibaba.com> From: Wen Yang Message-ID: Date: Fri, 8 Jan 2021 00:21:38 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/1/7 下午8:17, Greg Kroah-Hartman 写道: > On Thu, Jan 07, 2021 at 03:52:12PM +0800, Wen Yang wrote: >> The dentries such as /proc//ns/ have the DCACHE_OP_DELETE flag, they >> should be deleted when the process exits. >> >> Suppose the following race appears: >> >> release_task dput >> -> proc_flush_task >> -> dentry->d_op->d_delete(dentry) >> -> __exit_signal >> -> dentry->d_lockref.count-- and return. >> >> In the proc_flush_task(), if another process is using this dentry, it will >> not be deleted. At the same time, in dput(), d_op->d_delete() can be executed >> before __exit_signal(pid has not been hashed), d_delete returns false, so >> this dentry still cannot be deleted. >> >> This dentry will always be cached (although its count is 0 and the >> DCACHE_OP_DELETE flag is set), its parent denry will also be cached too, and >> these dentries can only be deleted when drop_caches is manually triggered. >> >> This will result in wasted memory. What's more troublesome is that these >> dentries reference pid, according to the commit f333c700c610 ("pidns: Add a >> limit on the number of pid namespaces"), if the pid cannot be released, it >> may result in the inability to create a new pid_ns. >> >> This issue was introduced by 60347f6716aa ("pid namespaces: prepare >> proc_flust_task() to flush entries from multiple proc trees"), exposed by >> f333c700c610 ("pidns: Add a limit on the number of pid namespaces"), and then >> fixed by 7bc3e6e55acf ("proc: Use a list of inodes to flush from proc"). > > Why are you just submitting a series for 4.9 and 4.19, what about 4.14? > We can't have users move to a newer kernel and then experience old bugs, > right? > Okay, the patches corresponding to 4.14 will be ready later. > But the larger question is why are you backporting a whole new feature > here? Why is CLONE_PIDFD needed? That feels really wrong... > The reason for backporting CLONE_PIDFD is because 7bc3e6e55acf ("proc: Use a list of inodes to flush from proc") relies on wait_pidfd.lock. There are indeed many associated modifications here. We are also testing it. Please check the code more. Thanks. -- Best wishes, Wen