Commit Graph

7837 Commits

Author SHA1 Message Date
Aleksa Sarai 62b107b73d VERSION: back to development
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2026-06-13 14:45:26 +02:00
Aleksa Sarai bb14dabeb7 VERSION: release v1.4.3
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.4.3
2026-06-13 14:45:15 +02:00
Aleksa Sarai 31d72bf86d merge CVE-2026-41579 fixes into release-1.4
Aleksa Sarai (3):
  rootfs: make cgroupv1 subsystem symlinks fd-based
  rootfs: make /dev initialisation code fd-based
  rootfs: switch createDevices argument order

LGTMs: lifubang kolyshkin rata
2026-06-13 13:59:44 +02:00
Aleksa Sarai b2b50a4fc5 rootfs: make cgroupv1 subsystem symlinks fd-based
As with /dev symlinks, this was missed in commit d40b3439a9 ("rootfs:
switch to fd-based handling of mountpoint targets"). It's not really
clear to what extent this was exploitable (/sys/fs/cgroup is a tmpfs we
create) but it's better to just fix this anyway.

Fixes: d40b3439a9 ("rootfs: switch to fd-based handling of mountpoint targets")
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
(cherry picked from commit 66acd48f9d)
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
2026-06-13 00:28:31 +02:00
Aleksa Sarai a7343f84f8 rootfs: make /dev initialisation code fd-based
These codepaths are very old and operate on pure paths but before
pivot_root(2), meaning that a bad image with a malicious /dev symlink
could cause us to operate on host paths instead.

In practice this means that we could be tricked into removing a file
called "ptmx" (note that /dev/pts/ptmx and /dev/ptmx are both immune for
different reasons) or creating a very restricted set of symlinks (with
fixed targets and names). The scope of these bugs is thus quite limited,
but we definitely need to harden against it.

These codepaths were unfortunately missed during the fd-based rework in
commit d40b3439a9 ("rootfs: switch to fd-based handling of mountpoint
targets") -- I must've assumed they were called after pivot_root(2)...

Fixes: GHSA-xjvp-4fhw-gc47
Fixes: CVE-2026-41579
Fixes: d40b3439a9 ("rootfs: switch to fd-based handling of mountpoint targets")
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
(cherry picked from commit 864db8042d)
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
2026-06-12 18:19:40 +02:00
Aleksa Sarai 5f2f6b56df rootfs: switch createDevices argument order
This argument order matches most other helpers we have and will also
match the changes we are about to make to setupPtmx and
setupDevSymlinks.

Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
(cherry picked from commit fcf04eb41b)
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
2026-06-12 18:19:40 +02:00
Akihiro Suda 6a7de4eb8b Merge pull request #5304 from ricardobranco777/1.4-5295
[1.4] Update busybox:glibc in integration tests to latest (1.38.0) builds
2026-05-28 13:52:21 +09:00
Ricardo Branco a753597a9d Update busybox:glibc in integration tests to latest (1.38.0) builds
This release fixes tests on ppc64le in busybox commit 3621595939e43:
"nsenter,unshare: don't use xvfork_parent_waits_and_exits(), it SEGVs
on ppc64le".

Fixes: https://github.com/opencontainers/runc/issues/4836

Signed-off-by: Ricardo Branco <rbranco@suse.de>
(cherry picked from commit c7c2920db0)
Signed-off-by: Ricardo Branco <rbranco@suse.de>
2026-05-27 12:17:08 +02:00
Tianon Gravi 3d7f70873f Update busybox:glibc in integration tests to latest (1.37.0) builds
This removes `mips64le` (no longer supported by the image / upstream in Debian Trixie+) and adds `riscv64`.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
(cherry picked from commit ce5400da08)
Signed-off-by: Ricardo Branco <rbranco@suse.de>
2026-05-27 12:17:04 +02:00
Ricardo Branco c6454efab9 tests/int: relax testPids fork error match string
The test checked for the exact BusyBox ash diagnostic "sh: can't fork".
With BusyBox 1.38, ash reports the failure as:

  /bin/sh: line 0: can't fork: Resource temporarily unavailable

Match the stable "can't fork" part of the error message instead.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
(cherry picked from commit de39d5e79b)
Signed-off-by: Ricardo Branco <rbranco@suse.de>
2026-05-27 10:30:21 +02:00
Ricardo Branco cae4907dbe tests/int: build TestPids pipelines programmatically
TestPids used long hand-written /bin/true pipelines for the 4-, 32- and
64-command cases. This made the test easy to typo and hard to review, as
seen by the earlier "bin/true" entries.

Build the shell pipelines instead, preserving the existing test coverage
while making the command counts explicit.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
(cherry picked from commit 3acb097f93)
Signed-off-by: Ricardo Branco <rbranco@suse.de>
2026-05-27 10:30:17 +02:00
Rodrigo Campos Catelin a03389556d Merge pull request #5287 from lifubang/backport-5269-1.4
[1.4] tests/int: fix flake in "resources.unified override" (backport #5269)
2026-05-22 10:29:20 +02:00
Kir Kolyshkin 3079745c6b Merge pull request #5281 from lifubang/backport-5275-1.4
[1.4] libct: reuse tmpfs for directory masks
2026-05-21 16:05:45 -07:00
lifubang 0d9be8021f libct: close rootFd ASAP in maskPaths
Close the root file descriptor immediately after use in maskPaths to
reduce the window during which an attacker could potentially exploit
an open fd to access or manipulate the root filesystem. This follows
the principle of least privilege and mitigates risks in compromised
or malicious container scenarios.

Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit b88635e57e)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:49 +00:00
lifubang 81d66c66f9 libct: optimize maskPaths for single-directory case
This is a follow-up to #5275. That change reused a single tmpfs mount
to mask multiple directories, which is efficient when masking more than
one path. However, it introduced unnecessary overhead when only one
directory is masked. This commit restores the original behavior for the
single-path case while preserving shared tmpfs logic for multiple paths.

Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit e7e2f00248)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:42 +00:00
lifubang e454170167 integration: reuse tmpfs for directory masks
Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 124772f354)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
lifubang 8dbcab66d1 libct: reuse tmpfs for directory masks
Kubernetes may add one sysfs thermal_throttle entry per CPU to
maskedPaths. On large Intel systems this can produce many directory
masks for a single container. runc currently handles each directory
mask with a separate read-only tmpfs mount, and therefore a separate
tmpfs superblock.

On Linux 4.18/RHEL 8 kernels, creating and tearing down many tmpfs
superblocks can contend on the global shrinker_rwsem when containers
start or stop concurrently.

Use one read-only tmpfs for directory masks and bind-mount it over the
remaining directory targets. The first non-procfs-fd directory mount is
reopened through the container root fd before it is reused. File masks
still bind /dev/null, and procfs fd targets keep the existing
one-tmpfs-per-target behaviour because they are fd aliases rather than
stable rootfs paths.

If the bind-mount of the shared source fails (e.g. due to kernel
restrictions), fall back to individual tmpfs mounts for all remaining
directories. Tmpfs mounts use nr_blocks=1,nr_inodes=1 to minimise
kernel resource usage.

The bind mounts do not create additional tmpfs superblocks. They also
retain the read-only mount flag inherited from the source vfsmount, so
the masking semantics remain unchanged.

xref: kubernetes/kubernetes#138512
xref: kubernetes/kubernetes#138388
xref: kubernetes/kubernetes#131018

Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Refactored-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit c046c9b973)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
lifubang abc399150b libct: enforce strict tmpfs limits for masked paths
Previously, masked directories (e.g., /proc/acpi, /proc/scsi) were
mounted as read-only tmpfs without explicit size or inode limits.
Although these mounts are meant to be empty and unwritable, the lack
of resource constraints means that—should an attacker bypass the
read-only protection (e.g., via container escape, mount namespace
manipulation, or a kernel vulnerability)—the tmpfs could consume up
to 50% of system memory by default (the kernel's default tmpfs limit).

To mitigate this risk in high-density container environments and
adhere to the principle of least privilege, we now explicitly set:
  - nr_blocks=1 (sufficient for at most one block size)
  - nr_inodes=1 (sufficient for at most one inode)
Ref: https://man7.org/linux/man-pages/man5/tmpfs.5.html

These limits ensure that even if compromised, kernel memory usage
remains strictly bounded and negligible.

This change aligns with best practices used by other container
runtimes and strengthens defense-in-depth for sensitive masked paths.

Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Refactored-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit e57a7a4c8f)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
lifubang b9e7a27a01 libct: skip mount for duplicate masked paths
Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Refactored-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit abf70bab63)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
lfbzhm 522b4c804e libct: use preopened rootfs more
This uses preopened rootfs in Chdir and pivotRoot.

While at it, add O_PATH when opening oldroot in pivotRoot.

Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 5b094ed1ac)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
Kir Kolyshkin aa769e7dcc Pre-open container root directory
A lot of filesystem-related stuff happens inside the container root
directory, and we have used its name before. It makes sense to pre-open
it and use a *os.File handle instead.

Function names in internal/pathrs are kept as is for simplicity (and it
is an internal package), but they now accept root as *os.File.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 28cb321887)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
Kir Kolyshkin 63857e5d20 libct: minor refactor in mountToRootfs
No change in functionality, just a preparation for the next patch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 78b80677f6)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
Kir Kolyshkin a4afb37ba7 libct: mountCgroupV1: address TODO
Indeed, it does not make sense to prepend c.root once we started using
MkdirAllInRoot in commit 63c29081.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 60352524d3)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 10:21:37 +00:00
Kir Kolyshkin 1191a315b7 tests/int: fix flake in "resources.unified override"
As runc binary grows in size over time (new features, more
dependencies) some tests start to flake because of low memory limits.

One such test is "runc run (cgroup v2 resources.unified override)";
it obviously fails because of 1M memory limit:

> runc run failed: unable to start container process: container init was OOM-killed (memory limit too low?)

Increase the limits 4x. Do the same for the "unified only" test.

Fixes issue 5264.

Reported-by: Kevin Berry <kpberry11@gmail.com>
Reported-by: Ricardo Branco <rbranco@suse.de>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 3fabb4d070)
Signed-off-by: lifubang <lifubang@acmcoder.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-05-18 13:49:21 +00:00
lfbzhm 4d5dc51e5d Merge pull request #5249 from AkihiroSuda/cherrypick-5239-1.4
[release-1.4] Complete migration from Cirrus CI to GHA (Lima)
2026-04-19 08:51:49 +08:00
Akihiro Suda 830d041dee CI: lima: add template name to cache key
The cache created for almalinux-8 could be overwritten for almalinux-9

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit ff4470156e)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-17 17:39:14 +09:00
Akihiro Suda fc8b6a01df Complete migration from Cirrus CI to GHA (Lima)
Fix issue 5238

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 9d697a9222)
(cherry-pick was not clean)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-16 22:22:50 +09:00
Rodrigo Campos Catelin f6d51d52e1 Merge pull request #5237 from kolyshkin/1.4-5222
[1.4] tests/int/checkpoint: drop unneeded tests
2026-04-13 11:15:36 +02:00
Kir Kolyshkin d3a0ee7c5b tests/int/checkpoint: drop unneeded tests
Those tests were added by commit 8d180e96 ("Add support for Linux
Network Devices"), apparently by copy-pasting the test cases which
call simple_cr (all four of them).

While different simple_cr tests make sense as they cover different
code paths in runc and/or check for various regression, the same
variations with netdevice do not make sense, as having a net device
is orthogonal to e.g. bind mount, --debug, or cgroupns.

Remove those.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 2cd4782b70)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-10 14:43:55 -07:00
Kir Kolyshkin d40e1ad2cf tests/int/checkpoint: fix using run twice
In our bats tests, runc itself is a wrapper which calls bats run helper,
so using "run runc" is wrong as it results in calling run helper twice.

Fixes: 8d180e965
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ad72eab6c7)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-10 14:43:20 -07:00
Kir Kolyshkin a5c14847f4 tests/int: remove useless/obvious comments
This is a bit opinionated, but some comments in integration tests do not
really help to understand the nature of the tests being performed by
stating something very obvious, like

	# run busybox detached
	runc run -d busybox

To make things worse, these not-so-helpful messages are being
copy/pasted over and over, and that is the main reason to remove them.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 0eb03ef86f)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-10 14:42:11 -07:00
lfbzhm 49e6be637f Merge pull request #5229 from kolyshkin/1.4-5226
[1.4] tests/rootless.sh: fix skipping idmap tests for systemd
2026-04-09 09:34:54 +08:00
Kir Kolyshkin ceb8e42641 tests/rootless.sh: fix skipping idmap tests for systemd
When RUNC_USE_SYSTEMD is set, tests/rootless.sh is using

	ssh -tt rootless@localhost

to run tests as rootless user. In this case, local environment is not
passed to the user's ssh session (unless explicitly specified), and so
the tests do not get ROOTLESS_FEATURES.

As a result, idmap-related tests are skipped when running as rootless
using systemd cgroup driver:

	integration test (systemd driver)
	...
	[02] run rootless tests ... (idmap)
	...
	ok 286 runc run detached ({u,g}id != 0) # skip test requires rootless_idmap
	...

Fix this by creating a list of environment variables needed by the
tests, and adding those to ssh command line (in case of ssh) or
exporting (in case of sudo) so both cases work similarly.

Also, modify disable_idmap to unset variables set in enable_idmap so
they are not exported at all if idmap is not in features.

Fixes: bf15cc99 ("cgroup v2: support rootless systemd")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 3e0829d195)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-08 10:59:44 -07:00
Kir Kolyshkin 59dd4cdee9 tests: rename AUX_{DIR,UID} to ROOTLESS_AUX_*
Also, fix the typo (AUX_DIX) in cleanup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ac2a53be8e)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-08 10:59:44 -07:00
Kir Kolyshkin a9669107ff Merge pull request #5217 from kolyshkin/1.4.2
Release 1.4.2
2026-04-02 17:02:19 -07:00
Kir Kolyshkin 814f276bb0 VERSION: back to development
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-02 15:52:51 -07:00
Kir Kolyshkin c241c0bb5e VERSION: release v1.4.2
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
v1.4.2
2026-04-02 15:52:45 -07:00
Rodrigo Campos Catelin 95f27e8053 Merge pull request #5216 from lifubang/backport-5210-1.4
[1.4] Fix SIGCHLD race in signal handler setup
2026-04-02 12:20:05 +02:00
lifubang 39791aeab6 Fix SIGCHLD race in signal handler setup
When signal installation was moved to a goroutine for performance,
containers that exited quickly could complete before SIGCHLD was
registered, causing runc to hang waiting for the signal.

This fix ensures SIGCHLD is registered immediately in the main thread
before other signals are handled in the goroutine, maintaining performance
while guaranteeing no missed SIGCHLD notifications for fast-exiting
containers.

Reported-by: Ayato Tokubi <atokubi@redhat.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 404181e4cc)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-04-02 01:11:45 +00:00
Aleksa Sarai 226ff030b4 Merge pull request #5201 from lifubang/backport-5177-1.4
[1.4] libct: close the mount source fd ASAP!
2026-03-29 19:56:11 +11:00
lifubang 9de77a986c test: check mount source fds are cleaned up with idmapped mounts
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 7fdab1cb69)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-03-28 15:16:13 +00:00
lifubang e4a82fc2d8 libct: close mount source fd as soon as possible
This commit factors out setupAndMountToRootfs without changing any
logic. Use "Hide whitespace changes" during review to focus on the
actual changes.

The refactor ensures the mount source file descriptor is closed via
defer in each loop iteration, reducing the total number of open FDs
in runc. This helps avoid hitting the file descriptor limit under
high concurrency or when handling many mounts.

Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit c77e71a3e7)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-03-28 15:16:06 +00:00
lifubang 87db63422d libct: add a nil check for mountError
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 0d0fd95731)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-03-28 15:15:56 +00:00
Rodrigo Campos Catelin d4305dc5dd Merge pull request #5187 from kolyshkin/1.4-5159
[1.4] ci: add conmon tests run
2026-03-20 13:56:48 +01:00
Kir Kolyshkin 63605fc49f ci: add conmon tests run
This adds a CI job to run conmon tests with runc.

Related to issue 5151, PR 5153.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 192e3d416f)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-03-19 16:55:08 -07:00
Aleksa Sarai 0daa0038d2 Merge pull request #5178 from kolyshkin/1.4-5175
[1.4] CHANGELOG: add "better errors from runc init" to 1.4.0
2026-03-17 10:25:02 +09:00
Kir Kolyshkin c10ee7d4b6 CHANGELOG: add "better errors from runc init" to 1.4.0
Found out that these changes were backported to release-1.4 (PR 5040)
and made its way into runc v1.4.0, but were missing from its CHANGELOG.

Add the item to v1.4.0 changelog.

Same as commit e232a54 in main branch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-03-16 10:42:29 -07:00
Kir Kolyshkin d13808e9d2 Merge pull request #5163 from kolyshkin/v141
VERSION: release 1.4.1
2026-03-12 21:56:37 -07:00
Kir Kolyshkin 6096163226 VERSION: back to development
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-03-12 13:27:50 -07:00
Kir Kolyshkin c671325303 VERSION: release v1.4.1
Note a few minor PRs were not mentioned: #5134, #5094, #5074.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
v1.4.1
2026-03-12 13:23:25 -07:00