Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2199250iof; Tue, 7 Jun 2022 23:00:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygbAyLj5YQnpVmH2xnf4QDzilQXYAI2EIxss4ryRZoSHF+PkvBhN/1oQPObXJK1lIgp4uX X-Received: by 2002:a17:90b:4b82:b0:1e6:7835:2f05 with SMTP id lr2-20020a17090b4b8200b001e678352f05mr35290799pjb.121.1654668013980; Tue, 07 Jun 2022 23:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668013; cv=none; d=google.com; s=arc-20160816; b=tpLx4RrjA8VtOW6XFFG9+a6NQHLxvvWVzSKQ843C7lVUFbvMKXVlfjklw02UXwHcrC zg2J6tEqd+DjR8GQ/xM0C+558EJaHH0Lvy0bsB97s+7d5Zf7F23hlMrAfPoHDnwfg40P qMcpMejfdLECgJa0niIzJnt5R3SLEj1A4jvzKwPQEPheKfwN6b/Yx3OK4lXQn95aX8u0 +BiZWJ+evOHKu9bgXaGjx6lZm8Ku+RQE1ve6/UIEhdT0CiBx8zGGPJA18FvdG/6Vo/d8 6QlcvPPNZ7rJMbJ48nRuR89XyJ7J0ENEyVHCQjbrnaPX+ZcP3H6NsFnyRDswd4LBwN7E 1HiQ== 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=2q5Rnnec7CIbGoPHHDmo3It9Y1I10j2BHDiCZO94atk=; b=qRHzVkxqVuNMWecKsyxAX7yn4RYskRxiwuCvJt7H+H8RCRqrQ2KYvOEIy3QBXa0pQE +0Elo9Tb+b7fLz7v+cAcnk1KSebH3Qb2A7TCaApGPtafTw1rsEQpKMh8u97rr3AUuk9k cYHVDHnji39w9zqTaNR1F1OYCyDkAJN1Iaqyjqt8IUwPyQ60P1RjJJI3vum4CHE31cFg lncxhAmjs2KrEg1reMfH4+0szUN+0kS7j8QHk9nK+b2lIv28SPU2VpmTnk9fm1akn5wr zRwMjvaM9Ke/I0u9GAXal71wOfug4LjyQ4B0AkF7ZO3yz33Rm5VC0M3XQrHz/mcHdidq shyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iCWviPm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p7-20020a170903248700b001582ce97029si25150062plw.122.2022.06.07.23.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:00:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iCWviPm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E7F96248532; Tue, 7 Jun 2022 22:24:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386071AbiFHBE4 (ORCPT + 99 others); Tue, 7 Jun 2022 21:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382627AbiFGVz5 (ORCPT ); Tue, 7 Jun 2022 17:55:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8772524CC86; Tue, 7 Jun 2022 12:13:46 -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 09916B8233E; Tue, 7 Jun 2022 19:13:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BACDC385A2; Tue, 7 Jun 2022 19:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629224; bh=TW1TVHmJIGoy6nezueTSKh5wbrNGBopgYLaRDfqALbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iCWviPm4wvS8/WFxS79uFNePmUqArOPMC2LcAUnUYRoVYSqz+yWxsS5G69lklOxef HWKoVCE7po1cq14tONJcU8hKZidehOS0y0yGbW877IIx0G9JWzsA4Poe3HQBzdVGta XmWY+CqUbFaFWHuRoKE9/2xCtWw5rIlirbGvqEv8= 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.18 614/879] proc: fix dentry/inode overinstantiating under /proc/${pid}/net Date: Tue, 7 Jun 2022 19:02:12 +0200 Message-Id: <20220607165020.670979168@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 f2132407e133..587b91d9d998 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -448,6 +448,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 e1cfeda397f3..913e5acefbb6 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c @@ -376,6 +376,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