[lxc-devel] [lxd/master] lxd/container: Protect file push/pull from shift

stgraber on Github lxc-bot at linuxcontainers.org
Mon Feb 10 21:50:07 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200210/f2d2cc0d/attachment.bin>
-------------- next part --------------
From 6428f8287f433bec7da838cb48e65457dba29c99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 10 Feb 2020 16:43:32 -0500
Subject: [PATCH] lxd/container: Protect file push/pull from shift
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6853

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 5f2f972754..361ff52d6e 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -5349,6 +5349,12 @@ func (c *containerLXC) FileExists(path string) error {
 }
 
 func (c *containerLXC) FilePull(srcpath string, dstpath string) (int64, int64, os.FileMode, string, []string, error) {
+	// Check for ongoing operations (that may involve shifting).
+	op := operationlock.Get(c.id)
+	if op != nil {
+		op.Wait()
+	}
+
 	var ourStart bool
 	var err error
 	// Setup container storage if needed
@@ -5472,6 +5478,12 @@ func (c *containerLXC) FilePull(srcpath string, dstpath string) (int64, int64, o
 }
 
 func (c *containerLXC) FilePush(type_ string, srcpath string, dstpath string, uid int64, gid int64, mode int, write string) error {
+	// Check for ongoing operations (that may involve shifting).
+	op := operationlock.Get(c.id)
+	if op != nil {
+		op.Wait()
+	}
+
 	var rootUid int64
 	var rootGid int64
 	var errStr string


More information about the lxc-devel mailing list