Re: [PATCH 2/2] LXC: make sure netns been enabled when trying to enable userns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 22, 2015 at 11:46:23PM -0400, Chen Hanxiao wrote:
> Discussed at:
> http://www.redhat.com/archives/libvir-list/2015-March/msg01023.html
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> ---
>  src/lxc/lxc_container.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index e34968a..69a8f2f 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -941,6 +941,16 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
>          bool bindOverReadonly;
>          virLXCBasicMountInfo const *mnt = &lxcBasicMounts[i];
>  
> +        /* When enable userns but disable netns, kernel will
> +         * forbid us doing a new fresh mount for sysfs for security reason.
> +         * So we should not allow this.
> +         */
> +        if (userns_enabled && netns_disabled) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Userns could not be enabled without netns"));
> +            goto cleanup;
> +        }
> +

These bools are just the idmap.nuidmap and nnets values from vmDef, so
this only depends on the domain definition.

I think we can reject this configuration much sooner, for exmaple in
lxcContainerStart.

Jan

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]