From d8d5ee24785182cbe30c01382d302618a20ee2ed Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 16 Jun 2022 09:57:10 -0700 Subject: [PATCH] [test] Signed-off-by: Kir Kolyshkin --- tests/integration/userns.bats | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/integration/userns.bats b/tests/integration/userns.bats index f6c677bcb26..d52444cacc5 100644 --- a/tests/integration/userns.bats +++ b/tests/integration/userns.bats @@ -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 ] +}