[lxc-devel] [lxc/master] Do remount with the MS_REMOUNT flag

lifeng68 on Github lxc-bot at linuxcontainers.org
Wed Feb 7 08:09:41 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 408 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180207/5a72eea8/attachment.bin>
-------------- next part --------------
From 745d3eaf88e3ea1757724622e2cd1f4a9d91c315 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68 at huawei.com>
Date: Wed, 7 Feb 2018 11:39:59 -0500
Subject: [PATCH] Do remount with the MS_REMOUNT flag

Remount with the MS_REMOUNT flag when mounts with MS_RDONLY

Signed-off-by: LiFeng <lifeng68 at huawei.com>
---
 src/lxc/cgroups/cgfsng.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index f4bec7f52..cf165a27b 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1947,6 +1947,15 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
 				cgpath);
 		return -1;
 	}
+
+	if (flags & MS_RDONLY) {
+		if (mount(sourcepath, cgpath, "cgroup", MS_REMOUNT | flags | MS_RDONLY, NULL) < 0) {
+			free(sourcepath);
+			SYSERROR("Error remounting %s read-only", cgpath);
+			return -1;
+		}
+	}
+
 	free(sourcepath);
 	INFO("Completed second stage cgroup automounts for %s", cgpath);
 	return 0;


More information about the lxc-devel mailing list