Skip to content

Commit

Permalink
Merge pull request #20096 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-20086-to-v4.7

[v4.7] specgen, rootless: fix mount of cgroup without a netns
  • Loading branch information
openshift-merge-robot authored Sep 25, 2023
2 parents 79e0d2a + 54ce0ca commit ccd3649
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/specgen/generate/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
}
g.AddMount(sysMnt)
g.RemoveMount("/sys/fs/cgroup")

sysFsCgroupMnt := spec.Mount{
Destination: "/sys/fs/cgroup",
Type: define.TypeBind,
Type: "cgroup",
Source: "/sys/fs/cgroup",
Options: []string{"rprivate", "nosuid", "noexec", "nodev", r, "rbind"},
Options: []string{"rprivate", "nosuid", "noexec", "nodev", r},
}
g.AddMount(sysFsCgroupMnt)
if !s.Privileged && isRootless {
Expand Down
4 changes: 4 additions & 0 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,10 @@ EOF
# verify that the last /sys/fs/cgroup mount is read-only
run_podman run --net=host --cgroupns=host --rm $IMAGE sh -c "grep ' / /sys/fs/cgroup ' /proc/self/mountinfo | tail -n 1"
assert "$output" =~ "/sys/fs/cgroup ro"

# verify that it works also with a cgroupns
run_podman run --net=host --cgroupns=private --rm $IMAGE sh -c "grep ' / /sys/fs/cgroup ' /proc/self/mountinfo | tail -n 1"
assert "$output" =~ "/sys/fs/cgroup ro"
fi
}

Expand Down

0 comments on commit ccd3649

Please sign in to comment.