Skip to content

Commit

Permalink
Revert "cgfs: don't mount /sys/fs/cgroup readonly"
Browse files Browse the repository at this point in the history
This reverts commit 8d783ed.
  • Loading branch information
stgraber committed May 2, 2014
1 parent 52b0a7d commit f8f3c3c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lxc/cgfs.c
Expand Up @@ -1413,6 +1413,14 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
SYSERROR("error bind-mounting %s to %s", mp->mount_point, abs_path);
goto out_error;
}
/* main cgroup path should be read-only */
if (type == LXC_AUTO_CGROUP_FULL_RO || type == LXC_AUTO_CGROUP_FULL_MIXED) {
r = mount(NULL, abs_path, NULL, MS_REMOUNT|MS_BIND|MS_RDONLY, NULL);
if (r < 0) {
SYSERROR("error re-mounting %s readonly", abs_path);
goto out_error;
}
}
/* own cgroup should be read-write */
if (type == LXC_AUTO_CGROUP_FULL_MIXED) {
r = mount(abs_path2, abs_path2, NULL, MS_BIND, NULL);
Expand Down Expand Up @@ -1479,6 +1487,14 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
parts = NULL;
}

/* try to remount the tmpfs readonly, since the container shouldn't
* change anything (this will also make sure that trying to create
* new cgroups outside the allowed area fails with an error instead
* of simply causing this to create directories in the tmpfs itself)
*/
if (type != LXC_AUTO_CGROUP_RW && type != LXC_AUTO_CGROUP_FULL_RW)
mount(NULL, path, NULL, MS_REMOUNT|MS_RDONLY, NULL);

free(path);

return true;
Expand Down

0 comments on commit f8f3c3c

Please sign in to comment.