Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2233825pxp; Mon, 21 Mar 2022 14:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1mGnqr258a8r/LQO+MC4OUEh7zFXEclZ4BygP81wABX28Z0j8tvCq+0r+W1ybs3osmsLm X-Received: by 2002:a63:dc53:0:b0:381:7f41:3a2d with SMTP id f19-20020a63dc53000000b003817f413a2dmr19684329pgj.126.1647898335167; Mon, 21 Mar 2022 14:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647898335; cv=none; d=google.com; s=arc-20160816; b=lYGFWLcNdfEyb4MOcRaaeTn0BrenbP3kQdnJiXBc2hCA5PzcTuhnM21V7JNFqeDWmz bB70uCN2+mkOa4WCjeLu1GrFKaq/iQ86vv6oThesRZXBdiU5DvhhR3Xncit4MgvtHj3P HobGQDhB5Iqya1QwR1ABLpA2Bsra98cRZA6oK6Cllzf1QRg7HdRz4g3CKFstkmfvDtNB wxY6bRE8NBY4pmcCiZwZbdtfUZkkkZtlATPTkoc89YA9BQnPrdZ/zAgaSuUhsIf/dGL1 OnafWrHqYjdQs7heTy+ruvOz/nTUkx4GAFjZ9LromTFN6vkkfEnv8vrcgHFef1nKKBR4 ETCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UDlYPAQBAOlLXBbFBOerVAwIN2CtIDqxO6mOQnxtBt8=; b=wQhJ49pkkgoEWGRJFV7TOOlcIZtvIRmy/TfiABQ/836uPGdjCl+9PdnVpHjQj9C0fo lthOIguYv+CJt5j+rl7bvpUgLWeCEpaxsR11DBIwKGEssuOSgccKWGRdd3PljlmVbq9T cEfDkXiS/mVTBgu9o0qb5Q7P4IYDUlD4LrLJ394U98xX9Ek0nXu3FEk6A0s+A7Tr04nR DYSuGFJYSEP3HrjDVsZBgUGkDZQvKALEr/i5ZuaRwq6FW/0Y1jmkMvXCARSxb2VVuc7l M987Zb/i+NBe2lghUhEzI8R4B/gQk6lEbmnwgrS/hYTJpnZ90K1YiKX+oLy35kDUZm5E fnHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W8Byhw7Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y64-20020a633243000000b003816043f0ffsi14629101pgy.756.2022.03.21.14.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:32:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W8Byhw7Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E2EB223853; Mon, 21 Mar 2022 14:11:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345766AbiCUJQk (ORCPT + 99 others); Mon, 21 Mar 2022 05:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236571AbiCUJQj (ORCPT ); Mon, 21 Mar 2022 05:16:39 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A360F33EA1; Mon, 21 Mar 2022 02:15:14 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id a11so7484251qtb.12; Mon, 21 Mar 2022 02:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=UDlYPAQBAOlLXBbFBOerVAwIN2CtIDqxO6mOQnxtBt8=; b=W8Byhw7YaHbu5C9YCddrrjz9P8+J4EhFPoPEWcsXXW1b7sOaCfegJrcK6DZhkDyc9b oLOXTXJK4Zwtr09FZhmSM8CvJC5UsvlUnD4+gFWtW5P3H/4mED8PfbagF4rpjrP4sscJ TkFrT6KdhDKZbE5V3ifobaWetZJN+m9cbwz+7y8nvt6J7CEzH9FqnT5xZZRw0lDnwOkB ElqLVe8UQ7xPH3U4QDaagnvdD4rWNWZ8KjVFyqt30SqRzPlCSvdmE6QBH0NV97FP4+sX lTYsw79fgdj/V5IaeeTP1GQLrCOaMuxsmm2VHRFR1+Ebk39iDKdaOMkS7tBnujXM5+9+ TmMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UDlYPAQBAOlLXBbFBOerVAwIN2CtIDqxO6mOQnxtBt8=; b=MOmIY+3//3H6DrWMaMtUOTLfxRscQYZsVmU2C7wJvEfmDhNK/6A/cxjA0W7Eg1BI2Q A0s1f9Ombd8dPnE9g3ldSv6zqwv0dP9vaLMIAO4V/Sfw316gE+tA9GfopL0ksmoqv8V9 xvQ2ZD2lmlKUchfGpXqZrA8xWYxQOGospJ0KQ0bi7JfX8SabZNHPQZ9bg+jx0Id5XK1U 7W/cOB4U6mQ6bIehiwL6HMWo9flj6nOeL8k5rTFss1EBiIg8HeqrFD+3O3TVkL5sG2Uv RDu6ZChHaQr3lxxmbYW24gtlAqci1jXWkN/eva5wVXZNA3bubAADAA8Q0Qf8SIqw7+4L oxog== X-Gm-Message-State: AOAM5315wCDWa7felJqPDRlF9O7zPxxCDBybiyl6SF7Hr3RX00yJUK5V KbsI/cH/1a+qEhM4xn9ik1vHXtdmri7xt4G5BligHGM6tuc= X-Received: by 2002:a05:622a:143:b0:2e0:b7c8:3057 with SMTP id v3-20020a05622a014300b002e0b7c83057mr15557151qtw.179.1647854113688; Mon, 21 Mar 2022 02:15:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: hui li Date: Mon, 21 Mar 2022 17:15:02 +0800 Message-ID: Subject: Re: [PATCH] proc: fix dentry/inode overinstantiating under /proc/${pid}/net To: Alexey Dobriyan Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 proc_misc_dentry_ops is a general ops for dentry under /proc, except for "/proc/${pid}/net"=EF=BC=8Cother dentries may also use there own ops to= o, so I think change proc_misc_d_delete may be better? see patch under: https://lkml.org/lkml/2022/3/17/319 Alexey Dobriyan =E4=BA=8E2022=E5=B9=B43=E6=9C=8821=E6= =97=A5=E5=91=A8=E4=B8=80 00:24=E5=86=99=E9=81=93=EF=BC=9A > > When a process exits, /proc/${pid}, and /proc/${pid}/net dentries are flu= shed. > 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 inherit= ing > proc_net_dentry_ops. > > Fixes: c6c75deda813 ("proc: fix lookup in /proc/net subdirectories after = setns(2)") > Reported-by: hui li > Signed-off-by: Alexey Dobriyan > --- > > fs/proc/generic.c | 4 ++++ > fs/proc/proc_net.c | 3 +++ > 2 files changed, 7 insertions(+) > > --- a/fs/proc/generic.c > +++ b/fs/proc/generic.c > @@ -448,6 +448,10 @@ static struct proc_dir_entry *__proc_create(struct p= roc_dir_entry **parent, > proc_set_user(ent, (*parent)->uid, (*parent)->gid); > > ent->proc_dops =3D &proc_misc_dentry_ops; > + /* Revalidate everything under /proc/${pid}/net */ > + if ((*parent)->proc_dops =3D=3D &proc_net_dentry_ops) { > + pde_force_lookup(ent); > + } > > out: > return ent; > --- 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 *ne= t) > > proc_set_user(netd, uid, gid); > > + /* Seed dentry revalidation for /proc/${pid}/net */ > + pde_force_lookup(netd); > + > err =3D -EEXIST; > net_statd =3D proc_net_mkdir(net, "stat", netd); > if (!net_statd)