Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp631752ybl; Wed, 8 Jan 2020 03:18:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwvSmmofhVXQkRoQjWOHCM1IbLWEtQPWy8dw/7drII3ucTwQ1ci+noVQaj47lpEcdnBEmUm X-Received: by 2002:a9d:74c7:: with SMTP id a7mr3953611otl.7.1578482336744; Wed, 08 Jan 2020 03:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578482336; cv=none; d=google.com; s=arc-20160816; b=xMap3+OgBzw3MQ/MSxhdKZqqC4AoM1gagvqvnvsQQlD1d1IH/C90WgMYVpMh9fPooo c4EAMbk4LQMakJ09DLGv1ALufmbKdAh/LuZ/7OvsAV55ApoR+EUsIxGXZLsAKTq6tXw6 ocevomrT/gVvkjBCYWHrx3knUlzW9pM9vT9+u9HZb4bNBidcatRWKz3mdTemS7VuOxzY HVBwVvjsboaw4RO3iC0S2JFJhiwbkfwtXlWYuODsdaAh//q4P46xT9i5CbOBiXWo9O54 Qrapdwzp+PpGlXlIz3tpZoltDH20lXF1NNfcozkfHZJz8nkpqp4CbbDmsu6/ucM/ru4v wWWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=Dsw2S2D490MNscsAl0q4Xt/af+VWkBVQ3mdpXhgs9u4=; b=GJB+BTq0uK9OVM6SpVP2Hdhjox5DxPrehAm9yJSUIylh8EccGDmqo7ZKKSkXq9USAh 0X4ghYJonDq35aiI7cmRJaYzEOcm7yEHSJ5adU9Ovab1YOhqlVtyfWRZYL6gk/Civv0U l9nixEHSusptp8GG4SkUiipYm3Uos9ZUx7PLElPGE6QT8ub/HJusDNJQMOoCTAD/tGwK TavL7rdME/JFEntUzgI+VO94UW6iRR2pOmZVxK5riy9W+yOu1YPzKiv4bOwGJZPXTvsn YWmFgK2Lf3AsZ+HcrNyUlKoZ1vH8mA/FD9E56qpuIbpFcqYggZGJhY6ZQw1EpjhnIWDU vcXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si1540318oic.163.2020.01.08.03.18.44; Wed, 08 Jan 2020 03:18:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgAHKhq (ORCPT + 99 others); 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