From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA77EC3B186 for ; Wed, 12 Feb 2020 19:50:33 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 4C3DB2467D for ; Wed, 12 Feb 2020 19:50:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="F1RTR2Mk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C3DB2467D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-17801-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 1343 invoked by uid 550); 12 Feb 2020 19:50:28 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 1323 invoked from network); 12 Feb 2020 19:50:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CHXH6o1ncLcAF0HeWBgC/IvihmP9toR2+/NwDUguxaw=; b=F1RTR2Mk3atysxi94JEv4Vc5seMqqx02k5CmzRHPSL9IrjapbyqOHw2Fl4dXiCvUEV ncTWbgP69pZD/8vVK6OQciM9WRN9WfMjKk6TsKRj9cuZUdWmWVaikWPX14ZlXYji3kdw CWzsabp8eT8r94ZjWLxWvcikM9+qEZil4HvcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CHXH6o1ncLcAF0HeWBgC/IvihmP9toR2+/NwDUguxaw=; b=NAaDTKe/rssObzd8wzLGqRXX8FbBjQB9NoMrjplloYwV7LagdPGGcHy2MXQJWp/Wzo iGVberIqsGSuoReTx5azSFz/eIRCQC06Uva2oD4G/ibTeXjDwN0OT5yu41565ba69ob9 jDYgeGmtU0o7fmW/d8bR3XEATAzbkOixejYV3unTsDCbh/3p2mVc2RRpAOFNvr5VW7tY dIg+uyE0xmj+CfzImYbYK+0eS05O5h362nUbKbeihGuSZhxvMb5xkwfhW5vO0atbTsdn +gb4NAng/ieMNHZVihvILI3iC4YuNtDcjsIKmSM7J/XHfNc9yyAV8W4Lqh9Gpd6KFOJP nXpQ== X-Gm-Message-State: APjAAAXZfl7AYX4DQgLyMsQ1AW80EEfPq0xhuKKEQDG3qVg8MQeSOw6k BahtBqmywdQt1y3JhL5lZFEWc9tfRsA= X-Google-Smtp-Source: APXvYqwj2FR+V8/HjAr6V7NjZUXMyAhwF0kWBgR0vM0h8FIAaNwvwDE0wnYKVLMQR2jO6q44eX4wwg== X-Received: by 2002:a2e:9841:: with SMTP id e1mr8512159ljj.23.1581537016290; Wed, 12 Feb 2020 11:50:16 -0800 (PST) X-Received: by 2002:a19:c82:: with SMTP id 124mr7333707lfm.152.1581537014849; Wed, 12 Feb 2020 11:50:14 -0800 (PST) MIME-Version: 1.0 References: <20200210150519.538333-1-gladkov.alexey@gmail.com> <20200210150519.538333-8-gladkov.alexey@gmail.com> <87v9odlxbr.fsf@x220.int.ebiederm.org> <20200212144921.sykucj4mekcziicz@comp-core-i7-2640m-0182e6> <87tv3vkg1a.fsf@x220.int.ebiederm.org> <87v9obipk9.fsf@x220.int.ebiederm.org> In-Reply-To: <87v9obipk9.fsf@x220.int.ebiederm.org> From: Linus Torvalds Date: Wed, 12 Feb 2020 11:49:58 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 07/11] proc: flush task dcache entries from all procfs instances To: "Eric W. Biederman" Cc: LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Daniel Micay , Djalal Harouni , "Dmitry V . Levin" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Oleg Nesterov , Solar Designer Content-Type: text/plain; charset="UTF-8" On Wed, Feb 12, 2020 at 11:18 AM Eric W. Biederman wrote: > > > So it's just fs_info that needs to be rcu-delayed because it contains > > that list. Or is there something else? > > The fundamental dcache thing we are playing with is: > > dentry = d_hash_and_lookup(proc_root, &name); > if (dentry) { > d_invalidate(dentry); > dput(dentry); > } Ahh. And we can't do that part under the RCU read lock. So it's not the freeing, it's the list traversal itself. Fair enough. Hmm. I wonder if we could split up d_invalidate(). It already ends up being two phases: first the unhashing under the d_lock, and then the recursive shrinking of parents and children. The recursive shrinking of the parent isn't actually interesting for the proc shrinking case: we just looked up one child, after all. So we only care about the d_walk of the children. So if we only did the first part under the RCU lock, and just collected the dentries (can we perhaps then re-use the hash list to collect them to another list?) and then did the child d_walk afterwards? Linus