From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbdKJKgw (ORCPT ); Fri, 10 Nov 2017 05:36:52 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:47671 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbdKJKgt (ORCPT ); Fri, 10 Nov 2017 05:36:49 -0500 X-Google-Smtp-Source: AGs4zMY79eGBiySau0z3U5arkDx4at3y0pIzyT7uWGqD4/aNC3uvijMZc1boYHQDTPX3GicI9U5WM5f9rnH8PBN0DCI= MIME-Version: 1.0 In-Reply-To: <1510244046-3256-4-git-send-email-tixxdz@gmail.com> References: <1510244046-3256-1-git-send-email-tixxdz@gmail.com> <1510244046-3256-4-git-send-email-tixxdz@gmail.com> From: Alexey Dobriyan Date: Fri, 10 Nov 2017 12:36:48 +0200 Message-ID: Subject: Re: [PATCH RFC v3 3/7] proc: add helpers to set and get proc hidepid and gid mount options To: Djalal Harouni Cc: Kees Cook , Alexey Gladkov , Andy Lutomirski , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, Greg Kroah-Hartman , Alexander Viro , Akinobu Mita , me@tobin.cc, Oleg Nesterov , Jeff Layton , Ingo Molnar , ebiederm@xmission.com, Linus Torvalds , Daniel Micay , Jonathan Corbet , bfields@fieldses.org, Stephen Rothwell , solar@openwall.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/9/17, Djalal Harouni wrote: > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > -static bool has_pid_permissions(struct pid_namespace *pid, > +static bool has_pid_permissions(struct proc_fs_info *fs_info, More "const". > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index 9abc370..bdd808d 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -476,11 +476,12 @@ struct inode *proc_get_inode(struct super_block *sb, > struct proc_dir_entry *de) > int proc_fill_super(struct super_block *s, void *data, int silent) > { > struct proc_fs_info *fs_info = proc_sb(s); > - struct pid_namespace *ns = get_pid_ns(fs_info->pid_ns); > struct inode *root_inode; > int ret; > > - if (!proc_parse_options(data, ns)) > + get_pid_ns(fs_info->pid_ns); > + > + if (!proc_parse_options(data, fs_info)) > return -EINVAL; > > /* User space would break if executables or devices appear on proc */ > diff --git a/fs/proc/internal.h b/fs/proc/internal.h > index 4a67188..10bc7be 100644 > --- a/fs/proc/internal.h > +++ b/fs/proc/internal.h > @@ -240,7 +240,7 @@ static inline void proc_tty_init(void) {} > * root.c > */ > extern struct proc_dir_entry proc_root; > -extern int proc_parse_options(char *options, struct pid_namespace *pid); > +extern int proc_parse_options(char *options, struct proc_fs_info > *fs_info); "extern" can be dropped if you're touching prototype anyway. > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->hide_pid; > +} > + > +static inline kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->pid_gid; > +} More "const". > @@ -59,6 +81,24 @@ static inline void proc_flush_task(struct task_struct > *task) > { > } > > +static inline void proc_fs_set_hide_pid(struct proc_fs_info *fs_info, int > hide_pid) > +{ > +} > + > +static inline void proc_fs_set_pid_gid(struct proc_info_fs *fs_info, kgid_t > gid) > +{ > +} > + > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return 0; > +} > + > +extern kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) ehh? > +{ > + return GLOBAL_ROOT_GID; > +} From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Dobriyan Subject: Re: [PATCH RFC v3 3/7] proc: add helpers to set and get proc hidepid and gid mount options Date: Fri, 10 Nov 2017 12:36:48 +0200 Message-ID: References: <1510244046-3256-1-git-send-email-tixxdz@gmail.com> <1510244046-3256-4-git-send-email-tixxdz@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <1510244046-3256-4-git-send-email-tixxdz@gmail.com> Sender: owner-linux-security-module@vger.kernel.org To: Djalal Harouni Cc: Kees Cook , Alexey Gladkov , Andy Lutomirski , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, Greg Kroah-Hartman , Alexander Viro , Akinobu Mita , me@tobin.cc, Oleg Nesterov , Jeff Layton , Ingo Molnar , ebiederm@xmission.com, Linus Torvalds , Daniel Micay , Jonathan Corbet , bfields@fieldses.org, Stephen Rothwell List-Id: linux-api@vger.kernel.org On 11/9/17, Djalal Harouni wrote: > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > -static bool has_pid_permissions(struct pid_namespace *pid, > +static bool has_pid_permissions(struct proc_fs_info *fs_info, More "const". > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index 9abc370..bdd808d 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -476,11 +476,12 @@ struct inode *proc_get_inode(struct super_block *sb, > struct proc_dir_entry *de) > int proc_fill_super(struct super_block *s, void *data, int silent) > { > struct proc_fs_info *fs_info = proc_sb(s); > - struct pid_namespace *ns = get_pid_ns(fs_info->pid_ns); > struct inode *root_inode; > int ret; > > - if (!proc_parse_options(data, ns)) > + get_pid_ns(fs_info->pid_ns); > + > + if (!proc_parse_options(data, fs_info)) > return -EINVAL; > > /* User space would break if executables or devices appear on proc */ > diff --git a/fs/proc/internal.h b/fs/proc/internal.h > index 4a67188..10bc7be 100644 > --- a/fs/proc/internal.h > +++ b/fs/proc/internal.h > @@ -240,7 +240,7 @@ static inline void proc_tty_init(void) {} > * root.c > */ > extern struct proc_dir_entry proc_root; > -extern int proc_parse_options(char *options, struct pid_namespace *pid); > +extern int proc_parse_options(char *options, struct proc_fs_info > *fs_info); "extern" can be dropped if you're touching prototype anyway. > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->hide_pid; > +} > + > +static inline kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->pid_gid; > +} More "const". > @@ -59,6 +81,24 @@ static inline void proc_flush_task(struct task_struct > *task) > { > } > > +static inline void proc_fs_set_hide_pid(struct proc_fs_info *fs_info, int > hide_pid) > +{ > +} > + > +static inline void proc_fs_set_pid_gid(struct proc_info_fs *fs_info, kgid_t > gid) > +{ > +} > + > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return 0; > +} > + > +extern kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) ehh? > +{ > + return GLOBAL_ROOT_GID; > +} From mboxrd@z Thu Jan 1 00:00:00 1970 From: adobriyan@gmail.com (Alexey Dobriyan) Date: Fri, 10 Nov 2017 12:36:48 +0200 Subject: [PATCH RFC v3 3/7] proc: add helpers to set and get proc hidepid and gid mount options In-Reply-To: <1510244046-3256-4-git-send-email-tixxdz@gmail.com> References: <1510244046-3256-1-git-send-email-tixxdz@gmail.com> <1510244046-3256-4-git-send-email-tixxdz@gmail.com> Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On 11/9/17, Djalal Harouni wrote: > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > -static bool has_pid_permissions(struct pid_namespace *pid, > +static bool has_pid_permissions(struct proc_fs_info *fs_info, More "const". > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index 9abc370..bdd808d 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -476,11 +476,12 @@ struct inode *proc_get_inode(struct super_block *sb, > struct proc_dir_entry *de) > int proc_fill_super(struct super_block *s, void *data, int silent) > { > struct proc_fs_info *fs_info = proc_sb(s); > - struct pid_namespace *ns = get_pid_ns(fs_info->pid_ns); > struct inode *root_inode; > int ret; > > - if (!proc_parse_options(data, ns)) > + get_pid_ns(fs_info->pid_ns); > + > + if (!proc_parse_options(data, fs_info)) > return -EINVAL; > > /* User space would break if executables or devices appear on proc */ > diff --git a/fs/proc/internal.h b/fs/proc/internal.h > index 4a67188..10bc7be 100644 > --- a/fs/proc/internal.h > +++ b/fs/proc/internal.h > @@ -240,7 +240,7 @@ static inline void proc_tty_init(void) {} > * root.c > */ > extern struct proc_dir_entry proc_root; > -extern int proc_parse_options(char *options, struct pid_namespace *pid); > +extern int proc_parse_options(char *options, struct proc_fs_info > *fs_info); "extern" can be dropped if you're touching prototype anyway. > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->hide_pid; > +} > + > +static inline kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->pid_gid; > +} More "const". > @@ -59,6 +81,24 @@ static inline void proc_flush_task(struct task_struct > *task) > { > } > > +static inline void proc_fs_set_hide_pid(struct proc_fs_info *fs_info, int > hide_pid) > +{ > +} > + > +static inline void proc_fs_set_pid_gid(struct proc_info_fs *fs_info, kgid_t > gid) > +{ > +} > + > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return 0; > +} > + > +extern kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) ehh? > +{ > + return GLOBAL_ROOT_GID; > +} -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <1510244046-3256-4-git-send-email-tixxdz@gmail.com> References: <1510244046-3256-1-git-send-email-tixxdz@gmail.com> <1510244046-3256-4-git-send-email-tixxdz@gmail.com> From: Alexey Dobriyan Date: Fri, 10 Nov 2017 12:36:48 +0200 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: [kernel-hardening] Re: [PATCH RFC v3 3/7] proc: add helpers to set and get proc hidepid and gid mount options To: Djalal Harouni Cc: Kees Cook , Alexey Gladkov , Andy Lutomirski , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, Greg Kroah-Hartman , Alexander Viro , Akinobu Mita , me@tobin.cc, Oleg Nesterov , Jeff Layton , Ingo Molnar , ebiederm@xmission.com, Linus Torvalds , Daniel Micay , Jonathan Corbet , bfields@fieldses.org, Stephen Rothwell , solar@openwall.com List-ID: On 11/9/17, Djalal Harouni wrote: > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > -static bool has_pid_permissions(struct pid_namespace *pid, > +static bool has_pid_permissions(struct proc_fs_info *fs_info, More "const". > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index 9abc370..bdd808d 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -476,11 +476,12 @@ struct inode *proc_get_inode(struct super_block *sb, > struct proc_dir_entry *de) > int proc_fill_super(struct super_block *s, void *data, int silent) > { > struct proc_fs_info *fs_info = proc_sb(s); > - struct pid_namespace *ns = get_pid_ns(fs_info->pid_ns); > struct inode *root_inode; > int ret; > > - if (!proc_parse_options(data, ns)) > + get_pid_ns(fs_info->pid_ns); > + > + if (!proc_parse_options(data, fs_info)) > return -EINVAL; > > /* User space would break if executables or devices appear on proc */ > diff --git a/fs/proc/internal.h b/fs/proc/internal.h > index 4a67188..10bc7be 100644 > --- a/fs/proc/internal.h > +++ b/fs/proc/internal.h > @@ -240,7 +240,7 @@ static inline void proc_tty_init(void) {} > * root.c > */ > extern struct proc_dir_entry proc_root; > -extern int proc_parse_options(char *options, struct pid_namespace *pid); > +extern int proc_parse_options(char *options, struct proc_fs_info > *fs_info); "extern" can be dropped if you're touching prototype anyway. > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->hide_pid; > +} > + > +static inline kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) > +{ > + return fs_info->pid_ns->pid_gid; > +} More "const". > @@ -59,6 +81,24 @@ static inline void proc_flush_task(struct task_struct > *task) > { > } > > +static inline void proc_fs_set_hide_pid(struct proc_fs_info *fs_info, int > hide_pid) > +{ > +} > + > +static inline void proc_fs_set_pid_gid(struct proc_info_fs *fs_info, kgid_t > gid) > +{ > +} > + > +static inline int proc_fs_hide_pid(struct proc_fs_info *fs_info) > +{ > + return 0; > +} > + > +extern kgid_t proc_fs_pid_gid(struct proc_fs_info *fs_info) ehh? > +{ > + return GLOBAL_ROOT_GID; > +}