• V
    selinux: Allow context mounts for unpriviliged overlayfs · 7fa2e79a
    Vivek Goyal 提交于
    Now overlayfs allow unpriviliged mounts. That is root inside a non-init
    user namespace can mount overlayfs. This is being added in 5.11 kernel.
    
    Giuseppe tried to mount overlayfs with option "context" and it failed
    with error -EACCESS.
    
    $ su test
    $ unshare -rm
    $ mkdir -p lower upper work merged
    $ mount -t overlay -o lowerdir=lower,workdir=work,upperdir=upper,userxattr,context='system_u:object_r:container_file_t:s0' none merged
    
    This fails with -EACCESS. It works if option "-o context" is not specified.
    
    Little debugging showed that selinux_set_mnt_opts() returns -EACCESS.
    
    So this patch adds "overlay" to the list, where it is fine to specific
    context from non init_user_ns.
    Reported-by: NGiuseppe Scrivano <gscrivan@redhat.com>
    Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
    [PM: trimmed the changelog from the description]
    Signed-off-by: NPaul Moore <paul@paul-moore.com>
    7fa2e79a
hooks.c 189.8 KB