Skip to content

[1.5] libct: fix sub-cgroup path check - #5457

Open
kolyshkin wants to merge 1 commit into
opencontainers:release-1.5from
kolyshkin:1.5-5403
Open

kolyshkin wants to merge 1 commit into
opencontainers:release-1.5from
kolyshkin:1.5-5403

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Backport of 7820c58 (the second commit) from #5403 to release-1.5.
The opencontainers/cgroups v0.1.0 bump from #5403 was already backported in #5428.

The relevant portion of original description follows.


This PR also improves the runc exec --cgroup sub-cgroup path check (see the
second commit).

@kolyshkin kolyshkin added the backport/1.5-pr A backport PR to release-1.5 label Sep 13, 2026
@kolyshkin kolyshkin added this to the 1.5.2 milestone Sep 13, 2026
@kolyshkin
kolyshkin requested a review from lifubang September 13, 2026 20:57
The check that a sub-cgroup path (as set by runc exec --cgroup, or
libcontainer's Process.SubCgroupPaths) does not escape the container's
cgroup was too lax: a plain prefix check also accepts a sibling cgroup
whose name starts with the container cgroup name (say, "../foo-suffix"
for a container cgroup named "foo").

For addIntoCgroupV1 (used for per-controller sub-cgroup paths, which
AddPid does not support) the resulting path is passed to WriteCgroupProc
as is, so the pid did end up in the sibling cgroup. For prepareCgroupFD
the subsequent cgroups.OpenFile call cleans the path, so nothing escaped
in practice, but the check was wrong nevertheless.

Use the same check as opencontainers/cgroups v0.0.9 does in AddPid, and
add test cases for both code paths.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 7820c58)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Comment thread CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.5-pr A backport PR to release-1.5 easy-to-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants