Skip to content

Commit 176969f

Browse files
authored
Merge pull request #5583 from kolyshkin/1.4-5403
[1.4] ci: fix govulncheck and check-go jobs; fix sub-cgroup path check
2 parents 3d3428a + 3a592f0 commit 176969f

122 files changed

Lines changed: 794 additions & 21039 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test.yml‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,20 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
os: [ubuntu-24.04, ubuntu-24.04-arm]
28-
go-version: [1.24.x, 1.25.x, 1.26.x]
28+
go-version: [1.26.x, 1.27.x]
2929
rootless: ["rootless", ""]
3030
race: ["-race", ""]
3131
criu: ["", "criu-dev"]
3232
exclude:
3333
# Disable most of criu-dev jobs, as they are expensive
3434
# (need to compile criu) and don't add much value/coverage.
3535
- criu: criu-dev
36-
go-version: 1.24.x
37-
- criu: criu-dev
38-
go-version: 1.25.x
36+
go-version: 1.26.x
3937
- criu: criu-dev
4038
rootless: rootless
4139
# Do race detection only with latest stable Go version.
4240
- race: -race
43-
go-version: 1.24.x
44-
- race: -race
45-
go-version: 1.25.x
41+
go-version: 1.26.x
4642

4743
runs-on: ${{ matrix.os }}
4844

‎.github/workflows/validate.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
pull_request:
1010
workflow_dispatch:
1111
env:
12-
GO_VERSION: 1.24
12+
GO_VERSION: 1.26
1313
permissions:
1414
contents: read
1515

@@ -41,7 +41,7 @@ jobs:
4141
sudo apt -qy install libseccomp-dev
4242
- uses: golangci/golangci-lint-action@v9
4343
with:
44-
version: v2.6
44+
version: v2.12
4545
skip-cache: true
4646
# Extra linters, only checking new code from a pull request to main.
4747
- name: lint-extra

‎CHANGELOG.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- For users making use of the `libpathrs` build tag, runc now depends on
1515
[libpathrs v0.2.5] or later, and attempting to build with older versions will
1616
cause compilation errors. (#5291, #5333)
17+
- Switched to opencontainers/cgroups v0.1.0, which no longer uses the
18+
high-level cilium/ebpf API to manage cgroup v2 device rules. As a result,
19+
the runc binary shrunk by about 1 MiB (7.5%) on amd64. (#5403, #5583)
1720

1821
[libpathrs v0.2.5]: https://github.com/cyphar/libpathrs/releases/tag/v0.2.5
1922

23+
### Fixed ###
24+
- Worked around a Linux kernel bug (present since kernel v6.17, fixed in v7.2)
25+
which caused the kernel to write past the end of the structure
26+
provided by userspace (runc). This resulted in memory corruption inside runc
27+
(manifesting as random crashes) when configuring device rules on cgroup v2
28+
systems. (#5403, #5583)
29+
- `runc exec --cgroup` (and the equivalent libcontainer `Process.SubCgroupPaths`
30+
API) no longer accepts a sub-cgroup path that escapes the container's cgroup
31+
into a sibling cgroup sharing the same name prefix. Note that using
32+
`--cgroup` requires the same privileges as running `runc exec` itself, so
33+
this is a correctness rather than a security fix. (#5403, #5583)
34+
- Fixed a missing `O_CLOEXEC` when opening the cgroup v2 directory to set up
35+
device rules. (#5403, #5583)
36+
2037

2138
## [1.4.3] - 2026-06-13
2239

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.25
1+
ARG GO_VERSION=1.26
22
ARG BATS_VERSION=v1.12.0
33
ARG LIBSECCOMP_VERSION=2.6.0
44

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/moby/sys/user v0.4.0
1616
github.com/moby/sys/userns v0.1.0
1717
github.com/mrunalp/fileutils v0.5.1
18-
github.com/opencontainers/cgroups v0.0.6
18+
github.com/opencontainers/cgroups v0.1.0
1919
github.com/opencontainers/runtime-spec v1.3.0
2020
github.com/opencontainers/selinux v1.13.0
2121
github.com/seccomp/libseccomp-golang v0.11.1

‎go.sum‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,10 @@ github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
2424
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
2525
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
2626
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
27-
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
28-
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
29-
github.com/jsimonetti/rtnetlink/v2 v2.0.1 h1:xda7qaHDSVOsADNouv7ukSuicKZO7GgVUCXxpaIEIlM=
30-
github.com/jsimonetti/rtnetlink/v2 v2.0.1/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE=
3127
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3228
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3329
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3430
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
35-
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
36-
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
37-
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
38-
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
3931
github.com/moby/sys/capability v0.4.0 h1:4D4mI6KlNtWMCM1Z/K0i7RV1FkX+DBDHKVJpCndZoHk=
4032
github.com/moby/sys/capability v0.4.0/go.mod h1:4g9IK291rVkms3LKCDOoYlnV8xKwoDTpIrNEE35Wq0I=
4133
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
@@ -46,8 +38,8 @@ github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g
4638
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
4739
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
4840
github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
49-
github.com/opencontainers/cgroups v0.0.6 h1:tfZFWTIIGaUUFImTyuTg+Mr5x8XRiSdZESgEBW7UxuI=
50-
github.com/opencontainers/cgroups v0.0.6/go.mod h1:oWVzJsKK0gG9SCRBfTpnn16WcGEqDI8PAcpMGbqWxcs=
41+
github.com/opencontainers/cgroups v0.1.0 h1:6W05KiDvgj1yi/6D13SJCvYx8TAESz67szvHPxhfcrs=
42+
github.com/opencontainers/cgroups v0.1.0/go.mod h1:hPBRvnBhLZueEN0eJyozMeM3HeFGYlZW9KnO//px6G4=
5143
github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg=
5244
github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
5345
github.com/opencontainers/selinux v1.13.0 h1:Zza88GWezyT7RLql12URvoxsbLfjFx988+LGaWfbL84=
@@ -81,8 +73,6 @@ github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zd
8173
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
8274
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
8375
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
84-
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
85-
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8676
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8777
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8878
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

‎libcontainer/process_linux.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ func (p *setnsProcess) addIntoCgroupV1() error {
276276
return fmt.Errorf("unknown controller %s in SubCgroupPaths", ctrl)
277277
}
278278
cgPath := path.Join(base, sub)
279-
if !strings.HasPrefix(cgPath, base) {
279+
// Make sure cgPath is either base itself or below it.
280+
if cgPath != base && !strings.HasPrefix(cgPath, base+"/") {
280281
return fmt.Errorf("bad sub cgroup path: %s", sub)
281282
}
282283
paths[ctrl] = cgPath
@@ -384,7 +385,8 @@ func (p *setnsProcess) prepareCgroupFD() (*os.File, error) {
384385
sub = p.process.SubCgroupPaths[""]
385386
}
386387
cgroup := path.Join(base, sub)
387-
if !strings.HasPrefix(cgroup, base) {
388+
// Make sure cgroup is either base itself or below it.
389+
if cgroup != base && !strings.HasPrefix(cgroup, base+"/") {
388390
return nil, fmt.Errorf("bad sub cgroup path: %s", sub)
389391
}
390392

‎tests/integration/exec.bats‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ function setup() {
77
}
88

99
function teardown() {
10+
# Remove the sibling cgroup created by "runc exec --cgroup" tests, if any.
11+
# It has to be removed before teardown_bundle, as the latter removes the
12+
# parent cgroup, which can't be done while it has any children.
13+
if [ -v SIBLING_CGROUP ]; then
14+
rmdir "$SIBLING_CGROUP"
15+
unset SIBLING_CGROUP
16+
fi
1017
teardown_bundle
1118
}
1219

@@ -214,6 +221,22 @@ function check_exec_debug() {
214221
[ "$status" -ne 0 ]
215222
[[ "$output" == *"bad sub cgroup path"* ]]
216223

224+
# Check we can't join a sibling cgroup sharing our name prefix.
225+
local cpu_path sibling
226+
cpu_path=$(get_cgroup_path cpu)
227+
sibling="$(basename "$cpu_path")-sibling"
228+
# SIBLING_CGROUP is removed by teardown.
229+
SIBLING_CGROUP="$(dirname "$cpu_path")/$sibling"
230+
mkdir "$SIBLING_CGROUP"
231+
runc exec --cgroup "../$sibling" test_busybox cat /proc/self/cgroup
232+
[ "$status" -ne 0 ]
233+
[[ "$output" == *"bad sub cgroup path"* ]]
234+
235+
# Same as above, for a particular controller.
236+
runc exec --cgroup "cpu:../$sibling" test_busybox cat /proc/self/cgroup
237+
[ "$status" -ne 0 ]
238+
[[ "$output" == *"bad sub cgroup path"* ]]
239+
217240
# Check we can't join non-existing subcgroup.
218241
runc exec --cgroup nonexistent test_busybox cat /proc/self/cgroup
219242
[ "$status" -ne 0 ]
@@ -265,6 +288,16 @@ function check_exec_debug() {
265288
[ "$status" -ne 0 ]
266289
[[ "$output" == *"bad sub cgroup path"* ]]
267290

291+
# Check we can't join a sibling cgroup sharing our name prefix.
292+
local sibling
293+
sibling="$(basename "$CGROUP_V2_PATH")-sibling"
294+
# SIBLING_CGROUP is removed by teardown.
295+
SIBLING_CGROUP="$(dirname "$CGROUP_V2_PATH")/$sibling"
296+
mkdir "$SIBLING_CGROUP"
297+
runc exec --cgroup "../$sibling" test_busybox cat /proc/self/cgroup
298+
[ "$status" -ne 0 ]
299+
[[ "$output" == *"bad sub cgroup path"* ]]
300+
268301
# Check we can't join non-existing subcgroup.
269302
runc exec --cgroup nonexistent test_busybox cat /proc/self/cgroup
270303
[ "$status" -ne 0 ]

‎vendor/github.com/cilium/ebpf/.clang-format‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎vendor/github.com/cilium/ebpf/.gitattributes‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)