[libvirt] [PATCH 2/2] LXC: make sure netns been enabled when trying to enable userns
Ján Tomko
jtomko at redhat.com
Tue Apr 7 10:49:58 UTC 2015
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 at cn.fujitsu.com>
> ---
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150407/e0675930/attachment-0001.sig>
More information about the libvir-list
mailing list