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.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,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 56D22C2D0DB for ; Mon, 27 Jan 2020 23:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 389252465B for ; Mon, 27 Jan 2020 23:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbgA0XYC (ORCPT ); Mon, 27 Jan 2020 18:24:02 -0500 Received: from monster.unsafe.ru ([5.9.28.80]:59724 "EHLO mail.unsafe.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgA0XYC (ORCPT ); Mon, 27 Jan 2020 18:24:02 -0500 Received: from comp-core-i7-2640m-0182e6 (ip-89-102-33-211.net.upcbroadband.cz [89.102.33.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.unsafe.ru (Postfix) with ESMTPSA id B5A60C61B0E; Mon, 27 Jan 2020 23:23:54 +0000 (UTC) Date: Tue, 28 Jan 2020 00:23:53 +0100 From: Alexey Gladkov To: Linus Torvalds 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" , "Eric W . Biederman" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Oleg Nesterov , Solar Designer , Stephen Rothwell Subject: Re: [PATCH v7 07/11] proc: flush task dcache entries from all procfs instances Message-ID: <20200127232352.s3mvvfkrta3i5h7w@comp-core-i7-2640m-0182e6> Mail-Followup-To: Linus Torvalds , 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" , "Eric W . Biederman" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Oleg Nesterov , Solar Designer , Stephen Rothwell References: <20200125130541.450409-1-gladkov.alexey@gmail.com> <20200125130541.450409-8-gladkov.alexey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Sat, Jan 25, 2020 at 10:45:25AM -0800, Linus Torvalds wrote: > On Sat, Jan 25, 2020 at 5:06 AM Alexey Gladkov wrote: > > > > This allows to flush dcache entries of a task on multiple procfs mounts > > per pid namespace. > > From a quick read-through, this is the only one I really react negatively to. > > The locking looks odd. It only seems to protect the new proc_mounts > list, but then it's a whole big rwsem, and it's taken over all of > proc_flush_task_mnt(), and the locking is exported to all over as a > result of that - including the dummy functions for "there is no proc" > case. > > And proc_flush_task_mnt() itself should need no locking over any of > it, so it's all just for the silly looping over the list. Thank you, I will rework this part. > So > > (a) this looks fishy and feels wrong - I get a very strong feeling > that the locking is wrong to begin with, and could/should have been > done differently > > (b) all the locking should have been internal to /proc, and those > wrappers shouldn't exist in a common header file (and certainly not > for the non-proc case). > > Yes, (a) is just a feeling, and I don't have any great suggestions. > Maybe make it an RCU list and use a spinlock for updating it? I’m thinking, is it possible to get rid of proc_flush_task at all ? Maybe we can try to flush dcache during readdir for example. > But (b) is pretty much a non-starter in this form. Those wrappers > shouldn't be in a globally exported core header file. No way. > > Linus > -- Rgrds, legion