]> git.ipfire.org Git - thirdparty/systemd.git/commit
nspawn: mount /sys as tmpfs, and then mount only select subdirs of the real sysfs...
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Sep 2015 11:47:28 +0000 (13:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 30 Sep 2015 13:19:33 +0000 (15:19 +0200)
commitd8fc6a000fe21b0c1ba27fbfed8b42d00b349a4b
tree7b21fcfde83588969aebf609e0ad835566a4358a
parent403af78c8049358496ec10920b3aaf741056daf9
nspawn: mount /sys as tmpfs, and then mount only select subdirs of the real sysfs below it

This way we can hide things like /sys/firmware or /sys/hypervisor from
the container, while keeping the device tree around.

While this is a security benefit in itself it also allows us to fix
issue #1277.

Previously we'd mount /sys before creating the user namespace, in order
to be able to mount /sys/fs/cgroup/* beneath it (which resides in it),
which we can only mount outside of the user namespace. To ensure that
the user namespace owns the network namespace we'd set up the network
namespace at the same time as the user namespace. Thus, we'd still see
the /sys/class/net/ from the originating network namespace, even though
we are in our own network namespace now. With this patch, /sys is
mounted before transitioning into the user namespace as tmpfs, so that
we can also mount /sys/fs/cgroup/* into it this early. The directories
such as /sys/class/ are then later added in from the real sysfs from
inside the network and user namespace so that they actually show whatis
available in it.

Fixes #1277
src/nspawn/nspawn-mount.c
src/nspawn/nspawn-mount.h
src/nspawn/nspawn.c