Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp257214pxu; Thu, 7 Jan 2021 04:19:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdJZIeRwRcLtVBqGFMIYmZcuFv+e/ru+RJ8dphVqvyv8GJxC3eqgyGHkdunGGelykEKzS9 X-Received: by 2002:aa7:c388:: with SMTP id k8mr1505877edq.36.1610021968245; Thu, 07 Jan 2021 04:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610021968; cv=none; d=google.com; s=arc-20160816; b=ruK4+gyouC3P22Nd4Q3xb4Dcwhe2woKnTK5MwxPZHXRS4eYSbDe2sIzT6tip4nUoar GBRq5r4mY6EiEH/v7imW4ETlJl5qRUe8xAepEDLsZelFaQoY1f2fL4/h7lN6Q78FQwhB cJbe75lkkRNl6MPfbSLh/6/DXsXRQj22aafmEy+rM92FBBMWOqb0vyZpdg7y7JliHxBC pfqNuA+NGMHdKEhfDF/XRd2oX2Sy236G/rfsj+NaL9B0FUHrzRs/+a6KebuZweaNeUdD /EmQ2Q/T02V+eds8/GmHqC1gncBgMvNB7ZByx8IozP7QnkdxKVrAp4rkWNnvS26md6Qc KVWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2N042EqXWDZe1X2e+OOTxBFBfOkjT8/1Xx8/UegOik4=; b=WLFj1GVaKk20UznEfRqijx/qfzU7fPVg0ZVbCrnEZzpdZ02KGoAuPCZ0PxOI37wz29 tVhYYQX5zqOY6zRgAJL0rMsaneqpJOnTY91uYUZ0+yMnC5RfhHOoi5ZGPr47ddoBlxtV o7XexZ/EWwlFKkqYBTXryIyXkRMe2hXVvnIGqJAQ/1RI+XrefZp0v+WHfVg5/B26hbgr edeF87iPOPzyl8fzCfmF2cUV1GyKOEPq46g/atyTw050qAoe/XtfIFk2zYCT7FKDetYK 586Slhswzfo5j1gnuQAOMymzkj5VKZDgXJVfgWJEozXE11TIJhlRB/E1AS/8pRLaxS2l 4Y8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UBYGHp4p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si2213033edt.257.2021.01.07.04.19.04; Thu, 07 Jan 2021 04:19:28 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UBYGHp4p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727733AbhAGMRR (ORCPT + 99 others); Thu, 7 Jan 2021 07:17:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:42586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbhAGMRQ (ORCPT ); Thu, 7 Jan 2021 07:17:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAB2D23359; Thu, 7 Jan 2021 12:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610021796; bh=MrM1/LVzBvycUoSWnH8Oj7Yg2SWMfo0FFP8owU5Stbs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UBYGHp4pt329Qv7BLbuDDktSU2MhFS5vXSqQRqd7nZzMz4I7cahCiCWdSmOHjE56R Xuy0ffJGQQIBMQwrYkM9MW0UHc3xyWQwiDFjVoyIotCXEyaQeSjfxD4T49cXMlt/y8 dAUgv57BIQ/c9OW4wykiV3lwpwv/b4bS8LGkOLRM= Date: Thu, 7 Jan 2021 13:17:55 +0100 From: Greg Kroah-Hartman To: Wen Yang Cc: Sasha Levin , Xunlei Pang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4.9 00/10] fix a race in release_task when flushing the dentry Message-ID: References: <20210107075222.62623-1-wenyang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210107075222.62623-1-wenyang@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? But the larger question is why are you backporting a whole new feature here? Why is CLONE_PIDFD needed? That feels really wrong... thanks, greg k-h