From: Cédric Bosdonnat Date: Mon, 24 Nov 2014 14:10:19 +0000 (+0100) Subject: lxc: don't unmount subtree if it contains the source of the mount X-Git-Tag: CVE-2014-8135~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e50457dd4cc5d4ba1ac7b05734157524620d087f;p=thirdparty%2Flibvirt.git lxc: don't unmount subtree if it contains the source of the mount The typical case where we had a problem is with such a filesystem definition as created by virt-sandbox-service: In this case, we don't want to unmount the /var subtree or we may loose the access to the source folder. --- diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 12f3a41a0f..334a1dfc6f 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1597,11 +1597,15 @@ static int lxcContainerMountAllFS(virDomainDefPtr vmDef, if (STREQ(vmDef->fss[i]->dst, "/")) continue; + VIR_DEBUG("Mounting '%s' -> '%s'", vmDef->fss[i]->src, vmDef->fss[i]->dst); + if (lxcContainerResolveSymlinks(vmDef->fss[i], false) < 0) return -1; - if (lxcContainerUnmountSubtree(vmDef->fss[i]->dst, - false) < 0) + + if (!(vmDef->fss[i]->src && + STRPREFIX(vmDef->fss[i]->src, vmDef->fss[i]->dst)) && + lxcContainerUnmountSubtree(vmDef->fss[i]->dst, false) < 0) return -1; if (lxcContainerMountFS(vmDef->fss[i], sec_mount_options) < 0)