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 C8FE5C33C9E for ; Wed, 8 Jan 2020 10:37:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A96A2206F0 for ; Wed, 8 Jan 2020 10:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727810AbgAHKhq (ORCPT ); Wed, 8 Jan 2020 05:37:46 -0500 Received: from monster.unsafe.ru ([5.9.28.80]:59224 "EHLO mail.unsafe.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbgAHKhq (ORCPT ); Wed, 8 Jan 2020 05:37:46 -0500 Received: from comp-core-i7-2640m-0182e6 (nat-pool-brq-t.redhat.com [213.175.37.10]) (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 64226C61AB0; Wed, 8 Jan 2020 10:37:42 +0000 (UTC) Date: Wed, 8 Jan 2020 11:37:41 +0100 From: Alexey Gladkov To: Alexey Dobriyan Cc: LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , 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 , Linus Torvalds , Oleg Nesterov , Solar Designer Subject: Re: [PATCH v6 00/10] proc: modernize proc to support multiple private instances Message-ID: <20200108103617.sowveextdxz5hkme@comp-core-i7-2640m-0182e6> Mail-Followup-To: Alexey Dobriyan , LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , 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 , Linus Torvalds , Oleg Nesterov , Solar Designer References: <20191225125151.1950142-1-gladkov.alexey@gmail.com> <20200106151514.GA382@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200106151514.GA382@avx2> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 06, 2020 at 06:15:14PM +0300, Alexey Dobriyan wrote: > > hidepid= Set /proc// access mode. > > gid= Set the group authorized to learn processes information. > > + pidonly= Show only task related subset of procfs. > > I'd rather have > > mount -t proc -o set=pid This is a great idea. > so that is can be naturally extended to > > mount -t proc -o set=pid,sysctl,misc > > > +static int proc_dir_open(struct inode *inode, struct file *file) > > +{ > > + struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb); > > + > > + if (proc_fs_pidonly(fs_info) == PROC_PIDONLY_ON) > > + return -ENOENT; > > + > > + return 0; > > +} > > + > > /* > > * These are the generic /proc directory operations. They > > * use the in-memory "struct proc_dir_entry" tree to parse > > @@ -338,6 +357,7 @@ static const struct file_operations proc_dir_operations = { > > .llseek = generic_file_llseek, > > .read = generic_read_dir, > > .iterate_shared = proc_readdir, > > + .open = proc_dir_open, > > This should not be necessary: if lookup and readdir filters work > then ->open can't happen. Yes you are right. > > --- a/include/linux/proc_fs.h > > +++ b/include/linux/proc_fs.h > > +/* definitions for hide_pid field */ > > +enum { > > + HIDEPID_OFF = 0, > > + HIDEPID_NO_ACCESS = 1, > > + HIDEPID_INVISIBLE = 2, > > + HIDEPID_NOT_PTRACABLE = 3, /* Limit pids to only ptracable pids */ > > +}; > > These should live in uapi/ as they _are_ user interface to mount(). OK. What do you think, maybe it's better to make these values a mask ? I mean: #define HIDEPID_OFF 0 #define HIDEPID_NO_ACCESS 1 #define HIDEPID_INVISIBLE 2 #define HIDEPID_NOT_PTRACABLE 4 In this case, if in the future there appear values that can be combined, then there will be no need to make additional parameters. -- Rgrds, legion