]> git.ipfire.org Git - thirdparty/lxc.git/commit
autodev: adapt to changes in Linux 4.18 2438/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 29 Jun 2018 11:58:52 +0000 (13:58 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 29 Jun 2018 12:36:13 +0000 (14:36 +0200)
commit3e04a6083eefe0b837db6d1b826721fd985ce052
treea4f0de43d079ed299b2b3221b48d5930e1da34fe
parent4c08bd46b96ebf81222990390795cff450ee7a5b
autodev: adapt to changes in Linux 4.18

Starting with commit
55956b59df33 ("vfs: Allow userns root to call mknod on owned filesystems.")
Linux will allow mknod() in user namespaces for userns root if CAP_MKNOD is
available.
However, these device nodes are useless since

static struct super_block *alloc_super(struct file_system_type *type, int flags,
                                       struct user_namespace *user_ns)
{
        /* <snip> */

        if (s->s_user_ns != &init_user_ns)
                s->s_iflags |= SB_I_NODEV;

        /* <snip> */
}

will set the SB_I_NODEV flag on the filesystem. When a device node created in
non-init userns is open()ed the call chain will hit:

bool may_open_dev(const struct path *path)
{
        return !(path->mnt->mnt_flags & MNT_NODEV) &&
                !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV);
}

which will cause an EPERM because the device node is located on an fs
owned by non-init-userns and thus doesn't grant access to device nodes due to
SB_I_NODEV.

The solution is straightforward. Unless you're real root you should bind-mount
device nodes.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c