]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/start.c
start: lxc_setup() after unshare(CLONE_NEWCGROUP)
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 1 Jun 2017 03:23:12 +0000 (05:23 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 24 Jul 2017 12:21:23 +0000 (14:21 +0200)
commitf4152036dd29d59c99e6a9415d6ea121f69c88ec
treebef27675bc0c379a5d9ccbab98911834c5d48d49
parentfa1bafd3f0e5f47823d2c6a95392c2c481bed17a
start: lxc_setup() after unshare(CLONE_NEWCGROUP)

When the running kernel supports cgroup namespaces and users want to manually
set up cgroups via lxc.hook.mount before the init binary starts the cgroup
namespace needs to be already unshared. Otherwise the view on the cgroup mounts
is wrong. This commit places the call to lxc_setup() after the
LXC_SYNC_POST_CGROUP barrier.

Before this commit, the tty fds we allocate from a fresh devpts instance in the
container's namespaces before the init binary starts were referring to the
host's cgroup namespace since lxc_setup() was called before
unshare(CLONE_NEWCGROUP). Although not a security risk at this point since
setns() restricts its calls to /proc/<self>/ns files it's still better to do it
*after* the cgroup namespace has been unshared.

Adding a Suggested-by line for the lxc.mount.hook fix for Quentin.

Closes #1597.

Suggested-by: Quentin Dufour <quentin@dufour.tk>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/start.c
src/lxc/sync.h