Commit Graph

8049 Commits

Author SHA1 Message Date
Rodrigo Campos Catelin a271890df2 Merge pull request #5297 from kolyshkin/fix-5203
runc list: fix error reporting for non-existent root
2026-05-26 17:18:47 +02:00
Kir Kolyshkin 98c442a0e6 runc list: fix error reporting for non-existent root
The idea of commit d1fca8e was right (report errors for non-existent
root, unless using the default root dir) but the logic was inverted.

Fix the logic.

Test case for default root requires non-existent /root/runc, which is
not always possible.

Reported-by: RedMakeUp <girafeeblue@gmail.com>
Co-authored-by: RedMakeUp <girafeeblue@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 17:31:42 -07:00
Rodrigo Campos Catelin d0aeb9e3e2 Merge pull request #5292 from opencontainers/dependabot/go_modules/golang.org/x/net-0.55.0
build(deps): bump golang.org/x/net from 0.54.0 to 0.55.0
2026-05-22 10:24:32 +02:00
dependabot[bot] 3003d0163c build(deps): bump golang.org/x/net from 0.54.0 to 0.55.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.54.0 to 0.55.0.
- [Commits](https://github.com/golang/net/compare/v0.54.0...v0.55.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.55.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-22 04:52:43 +00:00
Kir Kolyshkin 3e802d13d7 Merge pull request #5184 from lifubang/use-urfave-cli-v3
chore(deps): upgrade urfave/cli from v1 to v3
2026-05-19 22:40:02 -07:00
lifubang 098a2b4f49 remove urfave_cli_no_docs from build tags
After migrate from urfave/cli v1 (maintenance mode) to v3,
we don't need this build tag anymore.

Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 05:26:57 +00:00
lifubang 57fad01d52 chore(deps): upgrade urfave/cli from v1 to v3
Migrate from urfave/cli v1 (maintenance mode) to v3 to benefit from
active development, improved features, and long-term support.

Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-20 05:26:51 +00:00
Kir Kolyshkin 84762a5c1a Merge pull request #5285 from lifubang/followup-5275-maskpath
libct: Clean up and refactor maskPaths logic
2026-05-18 11:13:16 -07:00
lfbzhm 544621ae88 Merge pull request #5261 from kolyshkin/aa
Use sync.OnceFunc, sync.OnceValue[s]
2026-05-18 20:19:44 +08:00
lfbzhm e7b5943642 Merge pull request #5269 from kolyshkin/fix-5264
tests/int: fix flake in "resources.unified override"
2026-05-18 20:17:53 +08:00
lifubang b88635e57e 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>
2026-05-17 02:26:10 +00:00
lifubang e7e2f00248 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>
2026-05-16 05:50:01 +00:00
Kir Kolyshkin 16dde3befc libct/intelrdt: use sync.OnceFunc and sync.OnceValues
Switch from sync.Once to sync.OnceFunc and sync.OnceValues.

Keep Root a function (rather than a variable) because godoc
renders function doc better than a variable doc.

Switch to using internal function root internally.

Modify tests accordingly (and simplify NewIntelRdtTestUtil to
fakeRoot).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 2d2ae8809c libct/configs/validate: simplify intelrtd tests
The whole struct intelRdtStatus with its methods and a sync.Once is not
needed, since intelrtd.Is*Enabled methods are already run-once (or use
run-once and a simple comparison).

Yet it is still needed for the test to fake values returned by *Enabled.

Simplify to use func pointers which a test case overwrites.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 5cd0cb6d51 libct/intelrdt: remove newManager
It is not doing anything, and tests can just instantiate the &Manager{}.

Suggested-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 48c7e83b91 libcontainer/configs/validate: use early return
...in intelrdtCheck, like all other checks already do.

Best reviewed with --ignore-all-space.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 8d1ebab374 libct/utils: use sync.OnceValue
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 2ae07a45d6 libct/apparmor: simplify isEnabled
1. Use sync.OnceValue.

2. Fix the len(buf) check -- we only need 1 byte. Real kernel output
   is "Y\n" so practically this change is a no-op.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-15 17:14:15 -07:00
Kir Kolyshkin 3fabb4d070 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>
2026-05-13 11:16:08 -07:00
Kir Kolyshkin 95998b8a7f Merge pull request #5278 from opencontainers/dependabot/go_modules/github.com/opencontainers/selinux-1.14.1
build(deps): bump github.com/opencontainers/selinux from 1.13.1 to 1.14.1
2026-05-13 11:10:22 -07:00
lfbzhm df814a1d56 Merge pull request #5274 from opencontainers/dependabot/go_modules/golang.org/x/net-0.54.0
build(deps): bump golang.org/x/net from 0.53.0 to 0.54.0
2026-05-13 22:44:39 +08:00
dependabot[bot] 7fe4e42686 build(deps): bump golang.org/x/net from 0.53.0 to 0.54.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.53.0 to 0.54.0.
- [Commits](https://github.com/golang/net/compare/v0.53.0...v0.54.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.54.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-13 14:31:11 +00:00
lfbzhm 4d18d6f09e Merge pull request #5273 from opencontainers/dependabot/go_modules/golang.org/x/sys-0.44.0
build(deps): bump golang.org/x/sys from 0.43.0 to 0.44.0
2026-05-13 22:25:54 +08:00
dependabot[bot] a8c5fcbc7e build(deps): bump github.com/opencontainers/selinux
Bumps [github.com/opencontainers/selinux](https://github.com/opencontainers/selinux) from 1.13.1 to 1.14.1.
- [Release notes](https://github.com/opencontainers/selinux/releases)
- [Commits](https://github.com/opencontainers/selinux/compare/v1.13.1...v1.14.1)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/selinux
  dependency-version: 1.14.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-13 21:31:07 +08:00
dependabot[bot] 22986abb5f build(deps): bump golang.org/x/sys from 0.43.0 to 0.44.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.43.0 to 0.44.0.
- [Commits](https://github.com/golang/sys/compare/v0.43.0...v0.44.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.44.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-13 21:29:34 +08:00
Sebastiaan van Stijn 5847157c82 Merge pull request #5275 from lifubang/maskdir-with-shared-tmpfs
[Carry #5262] libct: reuse tmpfs for directory masks
2026-05-13 09:37:43 +02:00
lifubang 124772f354 integration: reuse tmpfs for directory masks
Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-13 13:05:32 +08:00
lifubang c046c9b973 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>
2026-05-13 13:05:32 +08:00
lifubang e57a7a4c8f 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>
2026-05-13 13:05:32 +08:00
lifubang abf70bab63 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>
2026-05-13 13:05:32 +08:00
Akihiro Suda a0f899b775 Merge pull request #5279 from kolyshkin/fix-fedora-exp
tests/rootless.sh: use command -v instead of which
2026-05-13 13:32:32 +09:00
Kir Kolyshkin 5e78f4a66d tests/rootless.sh: use command -v instead of which
Apparently, lima's experimental/fedora-rawhide image does not include
which rpm, and we don't really want to bother installing it.

Replace "which" with "command -v". Looks like this was the only place;
we already use "command -v" everywhere else.

This should fix lima (experimental/fedora-rawhide) CI.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-12 19:30:41 -07:00
Aleksa Sarai 0811f957a5 merge #5266 into opencontainers/runc:main
Kir Kolyshkin (3):
  runc exec -p: fix adding HOME to nil env
  tests/int/env.bats: add test for runc exec -p
  tests/int: amend runc exec --env test

LGTMs: rata cyphar
2026-05-11 13:50:36 +07:00
Kir Kolyshkin 321073efde runc exec -p: fix adding HOME to nil env
Before commit 7dc24868, when process.env was nil, prepareEnv
returned a flag telling HOME is not set, and it was added.

Commit 7dc24868 moved the functionality of adding HOME into
prepareEnv but did not properly handle nil case. As a result,
runc exec -p with process.json having no env set resulted in
an exec with no HOME set.

Fix this, and add unit and integration tests.

Fixes: 7dc24868 ("libct: switch to numeric UID/GID/groups")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:15:18 -07:00
Kir Kolyshkin d5307867f9 tests/int/env.bats: add test for runc exec -p
All existing tests check runc run, and there is no single runc exec
environment test except for one in exec.bats.

Add it (no new issues found).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:15:10 -07:00
Kir Kolyshkin 6210ceb856 tests/int: amend runc exec --env test
This tests checks that "runc exec --env VAR=VAR ..." actually appends
VAR=VAL to the exec's environment.

Add additional checks that:
 - process.env from config.json is also inherited;
 - HOME is set.

Those checks do not reveal any new issues.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:14:48 -07:00
Rodrigo Campos Catelin eb7eaf19b6 Merge pull request #5256 from kolyshkin/int-hook
Fix flakiness in TestHook
2026-04-22 14:18:23 +02:00
lfbzhm 543ef45b73 Merge pull request #5254 from AkihiroSuda/ci-rawhide
CI: lima: add fedora-rawhide
2026-04-22 18:47:31 +08:00
Kir Kolyshkin 1d12f98f85 tests/int: fix TestHook flakiness
Since commit 3cdda46 the poststart hooks runs after the container
process start, and so they race.

Move the poststart hook check to a separate step after the container
process has exited.

Fixes 5245.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-20 16:35:49 -07:00
Kir Kolyshkin 905958ea65 tests/int: show stderr if command failed part II
This adds a few cases missed by commit bf4fcc30.

Fixes: bf4fcc30
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-18 15:43:03 -07:00
Akihiro Suda f19a9e0917 CI: lima: add fedora-rawhide
For catching potential regressions in kernel, systemd, etc.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-17 17:45:52 +09:00
Kir Kolyshkin 4ccedcbfe8 Merge pull request #5250 from AkihiroSuda/ci-cache-lima
CI: lima: add template name to cache key
2026-04-16 12:06:58 -07:00
Akihiro Suda ff4470156e 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>
2026-04-16 22:30:11 +09:00
Rodrigo Campos Catelin 51d0c948d0 Merge pull request #5239 from AkihiroSuda/lima-actions
Complete migration from Cirrus CI to GHA (Lima)
2026-04-16 13:19:09 +02:00
Aleksa Sarai c5077eb39f merge #5243 into opencontainers/runc:main
Rodrigo Campos (1):
  libct/test: Disable GC on test run to catch leaking fds

LGTMs: kolyshkin cyphar
2026-04-16 14:55:36 +10:00
Rodrigo Campos 748af2e285 libct/test: Disable GC on test run to catch leaking fds
This test is racy for a long time now. All the logs I could find in CI
seem to be dangling symlinks, like the test shows "23 -> ". This means
the fd was closed before we did the call to readlink().

Let's try to disable the GC. This should get rid of the "fds are getting
closed before we read them" part.

Updates: #4297

Signed-off-by: Rodrigo Campos <rodrigo@amutable.com>
2026-04-15 17:08:29 -07:00
Rodrigo Campos Catelin 6f42442640 Merge pull request #5232 from kolyshkin/int-wait-stderr
libct/int: better error reporting
2026-04-15 18:22:42 +02:00
Kir Kolyshkin 9970cbfdb6 libct/int: switch from bytes.Buffer to strings.Builder
The latter is simpler and provides just enough functionality to be used
here.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:06 -07:00
Kir Kolyshkin 568a309225 libct/int: remove buffers.Stdin
It is never used.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:06 -07:00
Kir Kolyshkin 54be90bf68 libct/int: use readlink -v
By default, readlink is silent about any errors. Make it verbose so we
can better interpret any test failures.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:05 -07:00