All of lore.kernel.org
 help / color / mirror / Atom feed
* bind mounting namespace inodes for unprivileged users
@ 2016-05-03 18:20 James Bottomley
  2016-05-03 21:22 ` Serge Hallyn
       [not found] ` <1462299656.16133.51.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
  0 siblings, 2 replies; 18+ messages in thread
From: James Bottomley @ 2016-05-03 18:20 UTC (permalink / raw)
  To: Linux Containers, util-linux

Right at the moment, unprivileged users cannot call mount --bind to
create a permanent copy of any of their namespaces.  This is annoying
because it means that for entry to long running containers you have to
spawn an undying process and use nsenter via the /proc/<pid>/ns files.

The first question is:  assuming we restrict it to bind mounting only
nsfs inodes, is there any reason an unprivileged user shouldn't be able
to bind a namespace they've created to a file they own in the initial
mount namespace?

Assuming the answer to this is no, then how to implement it becomes the
next problem.  Right at the moment, util-linux/mount will deny a non
-root user the ability to use --bind.  This check could be relaxed and,
since mount is setuid root, it could be modified to force the binding
as root meaning this could be implemented entirely within the util
-linux package.

Doing this from within the kernel sys_mount is much more problematic:
no root users are forbidden from calling any type of mount by the
may_mount() check, which makes sure you only have root capability in
the user_ns attached to the current mnt_ns.  Overriding that simply to
allow nsfs binding looks like a recipe for introducing unexpected
security problems.

So, does anyone have any strong (or even weak) opinions about this
before I start coding patches?

James


^ permalink raw reply	[flat|nested] 18+ messages in thread
* bind mounting namespace inodes for unprivileged users
@ 2016-05-03 18:20 James Bottomley
  0 siblings, 0 replies; 18+ messages in thread
From: James Bottomley @ 2016-05-03 18:20 UTC (permalink / raw)
  To: Linux Containers, util-linux-u79uwXL29TY76Z2rM5mHXA

Right at the moment, unprivileged users cannot call mount --bind to
create a permanent copy of any of their namespaces.  This is annoying
because it means that for entry to long running containers you have to
spawn an undying process and use nsenter via the /proc/<pid>/ns files.

The first question is:  assuming we restrict it to bind mounting only
nsfs inodes, is there any reason an unprivileged user shouldn't be able
to bind a namespace they've created to a file they own in the initial
mount namespace?

Assuming the answer to this is no, then how to implement it becomes the
next problem.  Right at the moment, util-linux/mount will deny a non
-root user the ability to use --bind.  This check could be relaxed and,
since mount is setuid root, it could be modified to force the binding
as root meaning this could be implemented entirely within the util
-linux package.

Doing this from within the kernel sys_mount is much more problematic:
no root users are forbidden from calling any type of mount by the
may_mount() check, which makes sure you only have root capability in
the user_ns attached to the current mnt_ns.  Overriding that simply to
allow nsfs binding looks like a recipe for introducing unexpected
security problems.

So, does anyone have any strong (or even weak) opinions about this
before I start coding patches?

James

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-05-04 18:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 18:20 bind mounting namespace inodes for unprivileged users James Bottomley
2016-05-03 21:22 ` Serge Hallyn
2016-05-04 11:15   ` James Bottomley
2016-05-04 11:15   ` James Bottomley
     [not found] ` <1462299656.16133.51.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2016-05-03 21:22   ` Serge Hallyn
2016-05-04  8:44   ` Karel Zak
2016-05-04  8:44     ` Karel Zak
     [not found]     ` <20160504084403.7z67paycj663lkbt-xkT7n84Rsxv/9pzu0YdTqQ@public.gmane.org>
2016-05-04 13:16       ` James Bottomley
2016-05-04 13:16         ` James Bottomley
2016-05-04 14:38   ` Eric W. Biederman
2016-05-04 14:38     ` Eric W. Biederman
     [not found]     ` <87oa8lc2ic.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2016-05-04 17:28       ` James Bottomley
2016-05-04 17:28         ` James Bottomley
     [not found]         ` <1462382890.14310.67.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2016-05-04 17:43           ` Eric W. Biederman
2016-05-04 17:43         ` Eric W. Biederman
2016-05-04 18:00           ` James Bottomley
     [not found]           ` <87futx3eid.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2016-05-04 18:00             ` James Bottomley
  -- strict thread matches above, loose matches on Subject: below --
2016-05-03 18:20 James Bottomley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.