Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp584202iog; Mon, 13 Jun 2022 08:35:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1toxRTBtK1oMtHtB4MiIORk5ftckStSxxPfyfVoYXWBBYaI/wdFqGzhSrzOXY1r4v5IbeVz X-Received: by 2002:a17:907:60cb:b0:711:d516:ebab with SMTP id hv11-20020a17090760cb00b00711d516ebabmr371373ejc.159.1655134538734; Mon, 13 Jun 2022 08:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134538; cv=none; d=google.com; s=arc-20160816; b=lJ0+TLUyeIycAtz28y8vF28J3BYSxwtveuDi6rn8ahbtMyIEVq8Qi4NjI8vvKvUAO+ fcIGPgFpJWNmkEt4kfBWh94BMlwgdC0kSMls6HRi1MpJf+n4udbRjr0VFE8OCi1NT2ij JaemuWN0yH0P8IEhkUmADzfJI57Fj7QFbFmUQu7ojpEINTr8nwNWrRY/7sM3la/2XTxd FGi49ZowH9mS6JMrOD2jOpD4AYfyka1OpD8ja8Hnqpq2yMoo8OxCD3JbzrckVhO8Q/ee QNzCHVNE4FwMAwfSmxhKy6IkvZaFKxNYuuDS6E8vGNNAviSmCxwPYwU0REuDwCD3CGXm QbIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8CEPhC0HAGnUUFTjLox0VbA1PZGgZMK5Rnx+CGpbBig=; b=r27tFah4Y73fnRUe0k8yMt0kE/5SjILrdT80FB0Avsq48sbSh7T3iPDT4hYl7m/3F0 ln/RSqYlpZZJOjsdBRWSRWthG1yWQanOhlG3GxUURItX5LKejkbjzEKPOUhrIIIdHlbF c8CaTkReECFpuusYVf10XXlgKBH8fkiUkPkUrl1BhUqgQqKl8XOFbvC/aomHwoCWytun vnZim/h7uvUEbPBA/5ROEvezbcatGLkfL7nDnu+Ym7X7DwwfI5zLmsBRP6MC98/5y/NW 6HiNuCP/WexKKv017Z4/kUFcbxy9DakiTTnO3b2XNyimRQC8sxYbWYw3eL5S/86GFnel l64Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+2ct6BX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020a50e44e000000b0042f4ae66c4asi7779091edm.148.2022.06.13.08.35.14; Mon, 13 Jun 2022 08:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+2ct6BX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1353143AbiFMLY6 (ORCPT + 99 others); Mon, 13 Jun 2022 07:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352659AbiFMLQ5 (ORCPT ); Mon, 13 Jun 2022 07:16:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C87D038D8A; Mon, 13 Jun 2022 03:40:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CF615B80EAC; Mon, 13 Jun 2022 10:40:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17D2BC34114; Mon, 13 Jun 2022 10:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116813; bh=jbPHclukVovYqcjdvFI+HXUslo5TjyCHenAKCIjMEsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+2ct6BXJaJTpFdMr00tvy/go1cSSTRHd9I69hXU9xbqWjN0ySTf5wTCOTplzCzfm x4x0+Scee6Ub6gWMYqvtHKzMOoZmCodafT7JAfDzIK3jV8mS7bdcIxF3scJAxJA4Ch GJ8utM+5QbBKPQTOZTIH1mJQVzAWTnihObFhsTo0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Dobriyan , hui li , Al Viro , Andrew Morton , Sasha Levin Subject: [PATCH 5.4 182/411] proc: fix dentry/inode overinstantiating under /proc/${pid}/net Date: Mon, 13 Jun 2022 12:07:35 +0200 Message-Id: <20220613094934.116938638@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Dobriyan [ Upstream commit 7055197705709c59b8ab77e6a5c7d46d61edd96e ] When a process exits, /proc/${pid}, and /proc/${pid}/net dentries are flushed. However some leaf dentries like /proc/${pid}/net/arp_cache aren't. That's because respective PDEs have proc_misc_d_revalidate() hook which returns 1 and leaves dentries/inodes in the LRU. Force revalidation/lookup on everything under /proc/${pid}/net by inheriting proc_net_dentry_ops. [akpm@linux-foundation.org: coding-style cleanups] Link: https://lkml.kernel.org/r/YjdVHgildbWO7diJ@localhost.localdomain Fixes: c6c75deda813 ("proc: fix lookup in /proc/net subdirectories after setns(2)") Signed-off-by: Alexey Dobriyan Reported-by: hui li Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- fs/proc/generic.c | 3 +++ fs/proc/proc_net.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 8c3dbe13e647..372b4dad4863 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -446,6 +446,9 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, proc_set_user(ent, (*parent)->uid, (*parent)->gid); ent->proc_dops = &proc_misc_dentry_ops; + /* Revalidate everything under /proc/${pid}/net */ + if ((*parent)->proc_dops == &proc_net_dentry_ops) + pde_force_lookup(ent); out: return ent; diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 313b7c751867..9cd5b47199cb 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c @@ -343,6 +343,9 @@ static __net_init int proc_net_ns_init(struct net *net) proc_set_user(netd, uid, gid); + /* Seed dentry revalidation for /proc/${pid}/net */ + pde_force_lookup(netd); + err = -EEXIST; net_statd = proc_net_mkdir(net, "stat", netd); if (!net_statd) -- 2.35.1