Skip to content

fix depvpts in user namespaces

Glauber Costa cgroups containers linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 47 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4dev_cgroup: keep track of which cgroup is the root cgroupinclude/linux/security.h security/device_cgroup.c+14 -27 replies
2/4fs: allow dev accesses in userns in controlled situationsfs/namei.c fs/namespace.c include/linux/mount.h+7 -19 replies
3/4fs: allow mknod in user namespacesfs/namei.c+1 -112 replies
3/4fs: allow mknod in user namespacesfs/namei.c+1 -10 replies
4/4devpts: fix usage in user namespacesfs/devpts/inode.c+151 -62 replies
4/4devpts: fix usage in user namespacesfs/devpts/inode.c+151 -60 replies

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchSerge E. HallynAristeu Rozanski
1/4A-b A-b A-b
2/4A-b A-b
3/4A-b A-b
3/4A-b A-b
4/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] fix depvpts in user namespaces

Hi,

devpts mounts in user namespaces is queued for 3.9. However, while playing with it I found it to be less than ideal. Although it could possibly work with custom software that can be made to point to /dev/pts/ptmx, a few things prevent it from working correctly for people that, like us, are booting full distributions.

In those scenarios, things like udev will kick in, maybe remount /dev undoing any setup we might have done, and then software like sshd or anything else calling openpty will search for /dev/ptmx, not /dev/pts/ptmx.

One of the problems that I am addressing in here is that we are disallowing mknod in usernamespaces. Although I understand the motivation for that, I believe that to be too restrictive, specially because we already control access to the files separately. There should be no harm in mknod'ing something per se, if manipulating it is forbidden.

That too, however, is too restrictive. Following the precedence that we set by letting memcg manage the memory for tmpfs mounts, I am doing the same here with the device cgroup. With the exception that instead of suggesting, here we have a way to actually enforce it. Unless the mount was specifically marked as nodev, reads and writes will be allowed to proceed if a device cgroup is containing the process. The device cgroup will then be the one responsible for setting fine grained access about which devices can and cannot be manipulated.

Last, /dev/ptmx will still always be the global ptmx device. We need to somehow link it to our namespaces'. My proposal is to multiplex it and return the correct "root ptmx" depending on which userns is reading that device.

Glauber Costa (4):
dev_cgroup: keep track of which cgroup is the root cgroup
fs: allow dev accesses in userns in controlled situations
fs: allow mknod in user namespaces
devpts: fix usage in user namespaces

 fs/devpts/inode.c        | 157 +++++++++++++++++++++++++++++++++++++++++++++--
 fs/namei.c               |   6 +-
 fs/namespace.c           |   2 +-
 include/linux/mount.h    |   2 +
 include/linux/security.h |   1 +
 security/device_cgroup.c |  15 ++++-
 6 files changed, 173 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.1.2