Skip to content

Commit

Permalink
merge branch 'pr-3511' into release-1.1
Browse files Browse the repository at this point in the history
Kir Kolyshkin (1):
  libct: fix mounting via wrong proc fd

LGTMs: AkihiroSuda cyphar
Closes #3511
  • Loading branch information
cyphar committed Jul 20, 2022
2 parents 1e7bb5b + fa3354d commit afda6b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func prepareRootfs(pipe io.ReadWriter, iConfig *initConfig, mountFds []int) (err
// Therefore, we can access mountFds[i] without any concerns.
if mountFds != nil && mountFds[i] != -1 {
mountConfig.fd = &mountFds[i]
} else {
mountConfig.fd = nil
}

if err := mountToRootfs(m, mountConfig); err != nil {
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/userns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,22 @@ function teardown() {
runc exec test_busybox stat /tmp/mount-1/foo.txt /tmp/mount-2/foo.txt
[ "$status" -eq 0 ]
}

# Issue fixed by https://github.com/opencontainers/runc/pull/3510.
@test "userns with bind mount before a cgroupfs mount" {
# This can only be reproduced on cgroup v1 (and no cgroupns) due to the
# way it is mounted in such case (a bunch of of bind mounts).
requires cgroups_v1

# Add a bind mount right before the /sys/fs/cgroup mount,
# and make sure cgroupns is not enabled.
update_config ' .mounts |= map(if .destination == "/sys/fs/cgroup" then ({"source": "source-accessible/dir", "destination": "/tmp/mount-1", "options": ["bind"]}, .) else . end)
| .linux.namespaces -= [{"type": "cgroup"}]'

runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]

# Make sure this is real cgroupfs.
runc exec test_busybox cat /sys/fs/cgroup/{pids,memory}/tasks
[ "$status" -eq 0 ]
}

0 comments on commit afda6b7

Please sign in to comment.