Skip to content

Commit

Permalink
proc: Restrict mounting the proc filesystem
Browse files Browse the repository at this point in the history
Don't allow mounting the proc filesystem unless the caller has
CAP_SYS_ADMIN rights over the pid namespace.  The principle here is if
you create or have capabilities over it you can mount it, otherwise
you get to live with what other people have mounted.

Andy pointed out that this is needed to prevent users in a user
namespace from remounting proc and specifying different hidepid and gid
options on already existing proc mounts.

Cc: stable@vger.kernel.org
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
  • Loading branch information
ebiederm committed Aug 26, 2013
1 parent 5ff9d8a commit aee1c13
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
ns = task_active_pid_ns(current);
options = data;

if (!current_user_ns()->may_mount_proc)
if (!current_user_ns()->may_mount_proc ||
!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);
}

Expand Down

0 comments on commit aee1c13

Please sign in to comment.