Skip to content

Bump oc/cgroups to v0.1.0, improve sub-cgroup checks - #5403

Open
kolyshkin wants to merge 2 commits into
opencontainers:mainfrom
kolyshkin:cgroups009
Open

Bump oc/cgroups to v0.1.0, improve sub-cgroup checks#5403
kolyshkin wants to merge 2 commits into
opencontainers:mainfrom
kolyshkin:cgroups009

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

For oc/cgroups release notes, see

Notably, v0.1.0 no longer uses the high-level cilium/ebpf API (btf, link,
and the ELF loader) to manage cgroup v2 device rules. For runc, this means:

  • the binary is about 1 MiB (7.5%) smaller -- 13354888 vs 14443648 bytes for
    a seccomp libpathrs build with go1.26.5 on amd64;
  • about 20K lines of vendored code are gone;
  • five transitive dependencies are no longer needed: josharian/native,
    jsimonetti/rtnetlink, mdlayher/netlink, mdlayher/socket, and
    golang.org/x/sync;
  • the govulncheck warnings are fixed.

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

@kolyshkin kolyshkin added the backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 label Aug 14, 2026
@kolyshkin kolyshkin added this to the 1.6.0-rc.1 milestone Aug 14, 2026
@kolyshkin

Copy link
Copy Markdown
Contributor Author

Because of opencontainers/cgroups#69 I want to backport this to at least 1.5 but maybe also 1.4. I mean, a buffer overrun from the kernel is no joke.

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin kolyshkin changed the title Bump oc/cgroups to v0.0.9, improve sub-cgroup checks Bump oc/cgroups to v0.1.0, improve sub-cgroup checks Aug 19, 2026
kolyshkin and others added 2 commits August 18, 2026 23:29
See https://github.com/opencontainers/cgroups/releases/tag/v0.1.0

Notably, it no longer uses the high-level cilium/ebpf API (btf, link, and
the ELF loader) to manage cgroup v2 device rules, which makes the runc
binary about 1 MiB (7.5%) smaller on amd64, removes ~20K lines of vendored
code, and drops five transitive dependencies (josharian/native,
jsimonetti/rtnetlink, mdlayher/netlink, mdlayher/socket, golang.org/x/sync).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.5-todo A PR in main branch which needs to be backported to release-1.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants