7561 Commits

Author SHA1 Message Date
Kir Kolyshkin 657ab785d3 ci: bump bats to v0.11.0
This is the version available from Fedora 41.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit d31e6b87ca)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:18 -07:00
Kir Kolyshkin 6a249199fb script/setup_host_fedora.sh: use bash arrays
This makes the code more robust and allows to remove the
"shellcheck disable=SC2086" annotation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 8e653e40c6)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:18 -07:00
Kir Kolyshkin 477391a743 script/setup_host_fedora.sh: remove -p from mkdir
1. There is no need to have -p option in mkdir here, since
   /home/rootless was already created by useradd above.

2. When there is no -p, there is no need to suppress the shellcheck
   warning (which looked like this):

> In script/setup_host_fedora.sh line 21:
> mkdir -m 0700 -p /home/rootless/.ssh
>       ^-- SC2174 (warning): When used with -p, -m only applies to the deepest directory.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit a76a1361b4)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:10 -07:00
Kir Kolyshkin d230ee59f9 tests/int: rm some "shellcheck disable" annotations
Those are no longer needed with shellcheck v0.10.0 (possibly with an
earlier version, too, but I am too lazy to check that).

While at it, fix a typo in the comment.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit af386d1df1)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:10 -07:00
Kir Kolyshkin bcc92067e2 ci: bump shellcheck to v0.10.0
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b48dd65114)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:01 -07:00
Kir Kolyshkin a46cf790f9 Makefile: bump shfmt to v3.11.0
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 6e5ffb7cbc)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-22 00:35:01 -07:00
lfbzhm d54dffcc78 Merge pull request #4719 from kolyshkin/1.3-4709
[1.3] runc pause/unpause/ps: get rid of excessive warning
2025-04-10 07:06:56 +08:00
Kir Kolyshkin bac5261402 Merge pull request #4712 from rata/runc-1.3-rc.2
Release 1.3.0-rc.2
2025-04-09 15:31:04 -07:00
Kir Kolyshkin 6d667629f3 runc pause/unpause/ps: get rid of excessive warning
This issue was originally reported in podman PR 25792.

When calling runc pause/unpause for an ordinary user, podman do not
provide --systemd-cgroups option, and shouldUseRootlessCgroupManager
returns true. This results in a warning:

	$ podman pause sleeper
	WARN[0000] runc pause may fail if you don't have the full access to cgroups
	sleeper

Actually, it does not make sense to call shouldUseRootlessCgroupManager
at this point, because we already know if we're rootless or not, from
the container state.json (same for systemd).

Also, busctl binary is not available either in this context, so
shouldUseRootlessCgroupManager would not work properly.

Finally, it doesn't really matter if we use systemd or not, because we
use fs/fs2 manager to freeze/unfreeze, and it will return something like
EPERM (or tell that cgroups is not configured, for a true rootless
container).

So, let's only print the warning after pause/unpause failed,
if the error returned looks like a permission error.

Same applies to "runc ps".

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit c5ab4b6e30)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-09 09:29:18 -07:00
Kir Kolyshkin 763f3d589a pause: refactor
This is to simplify code review for the next commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit fda034c9ec)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-09 09:29:18 -07:00
Rodrigo Campos 55e45c645c VERSION: back to development
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-04-09 12:10:07 +02:00
Rodrigo Campos 159c67f8e2 VERSION: Release v1.3.0-rc.2
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
v1.3.0-rc.2
2025-04-09 12:10:07 +02:00
Rodrigo Campos d8e6733e9e CHANGELOG: port 1.2.x changes
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-04-09 12:10:07 +02:00
Akihiro Suda 6994570fe1 Merge pull request #4711 from rata/runc-1.3-env-fixes
[1.3]  Override HOME if its set to the empty string #4704
2025-04-08 02:59:12 +09:00
Rodrigo Campos 713045eda1 tests: Add env var tests
This adds some e2e tests for environment variables set in the
config.json. These were based on tests that failed on docker CI[1][2] after
the refactor on 06f1e0765 ("libct: speedup process.Env handling") and
some bugs that I had along the way trying to fix it.

These tests pass with runc 1.2 too.

[1]: https://github.com/moby/moby/blob/843e51459f14ebc964d349eba1013dc8a3e9d52e/integration-cli/docker_cli_run_test.go#L822-L843
[2]: https://github.com/moby/moby/blob/843e51459f14ebc964d349eba1013dc8a3e9d52e/integration-cli/docker_cli_links_test.go#L197-L204

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 19c6515471)
2025-04-07 14:17:19 +02:00
Rodrigo Campos 8dd36d11ce libct: Override HOME if its set to the empty string
Before commit 06f1e0765 ("libct: speedup process.Env handling") we were
overriding HOME if it was set to "" too[1]. But now we only override it
if it wasn't set at all.

This patch restores the old behavior of overriding it if it was set to
an empty value.

Docker relies on this behaviour since ages[2].

[1]: https://github.com/opencontainers/runc/blob/1c508045727231e7342e258ab30add1478c1f981/libcontainer/init_linux.go#L544-L549
[2]: https://github.com/moby/moby/blob/843e51459f14ebc964d349eba1013dc8a3e9d52e/integration-cli/docker_cli_run_test.go#L822-L843

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 09501d96d2)
2025-04-07 14:17:11 +02:00
Rodrigo Campos fa44e9d503 Merge pull request #4705 from kolyshkin/1.3-4696
[1.3] criu: Add time namespace to container config after checkpoint/restore
2025-04-02 05:44:06 -03:00
Rodrigo Campos 8e22c9b531 Merge pull request #4706 from kolyshkin/1.3-4693
[1.3] libct: we should set envs after we are in the jail of the container
2025-04-02 05:37:54 -03:00
lifubang a56f2bc836 libct: we should set envs after we are in the jail of the container
Because we have to set a default HOME env for the current container
user, so we should set it after we are in the jail of the container,
or else we'll use host's `/etc/passwd` to get a wrong HOME value.
Please see: #4688.

Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit bf38646497)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-01 17:25:45 -07:00
lifubang 73973fb03a test: check whether runc set a correct default home env or not
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 4a0e282b09)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-01 17:25:45 -07:00
Andrei Vagin 109116ae48 criu: Add time namespace to container config after checkpoint/restore
Since v3.14, CRIU always restores processes into a time namespace to
prevent backward jumps of monotonic and boottime clocks. This change
updates the container configuration to ensure that `runc exec` launches
new processes within the container's time namespace.

Fixes #2610

Signed-off-by: Andrei Vagin <avagin@gmail.com>
(cherry picked from commit b68cbdff34)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-01 16:46:51 -07:00
Akihiro Suda 6879a88705 Merge pull request #4677 from kolyshkin/1.3-4671
[1.3] .cirrus.yml: install less dependencies
2025-03-14 09:08:58 +09:00
Kir Kolyshkin c991b26619 .cirrus.yml: install less dependencies
In a nutshell:
 - use git-core instead of git;
 - do not install weak deps;
 - do not install docs.

This results in less packages to install:
 - 25 instead of 72 for almalinux-8
 - 24 instead of 90 for almalinux-9

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 1d9bea5378)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-13 11:19:03 -07:00
lfbzhm 1ffd46f6d2 Merge pull request #4667 from AkihiroSuda/cherrypick-4664
[1.3] CI: migrate Vagrant + Cirrus to Lima + GHA
2025-03-10 19:26:43 +08:00
Akihiro Suda ffbb1dd913 CI: migrate Vagrant + Cirrus to Lima + GHA
- Unlike proprietary Vagrant, Lima remains to be an open source project
- GHA now natively supports nested virt on Linux runners

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 135552e5e4)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-09 02:48:36 +09:00
Rodrigo Campos c5a654e4e6 Merge pull request #4665 from lifubang/fix-doc-spec-1.2.1-in-release-1.3
[1.3] doc: update spec-conformance.md
2025-03-07 11:05:43 -03:00
lifubang 473c740eed doc: update spec-conformance.md
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 79e9cf53e0)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-03-07 10:39:09 +00:00
Rodrigo Campos a00ce11e91 VERSION: release v1.3.0-rc.1
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cyphar: improve changelog)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.3.0-rc.1
2025-03-04 18:42:08 +11:00
lfbzhm 0ebf33109b Merge pull request #4327 from kolyshkin/exec-cpu-aff
runc exec: implement CPU affinity
2025-03-03 17:57:45 +08:00
Kir Kolyshkin 10ca66bff5 runc exec: implement CPU affinity
As per
- https://github.com/opencontainers/runtime-spec/pull/1253
- https://github.com/opencontainers/runtime-spec/pull/1261

CPU affinity can be set in two ways:
1. When creating/starting a container, in config.json's
   Process.ExecCPUAffinity, which is when applied to all execs.
2. When running an exec, in process.json's CPUAffinity, which
   applied to a given exec and overrides the value from (1).

Add some basic tests.

Note that older kernels (RHEL8, Ubuntu 20.04) change CPU affinity of a
process to that of a container's cgroup, as soon as it is moved to that
cgroup, while newer kernels (Ubuntu 24.04, Fedora 41) don't do that.

Because of the above,
 - it's impossible to really test initial CPU affinity without adding
   debug logging to libcontainer/nsenter;
 - for older kernels, there can be a brief moment when exec's affinity
   is different than either initial or final affinity being set;
 - exec's final CPU affinity, if not specified, can be different
   depending on the kernel, therefore we don't test it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-02 19:17:41 -08:00
Aleksa Sarai 701516b57a merge #4654 into opencontainers/runc:main
lifubang (1):
  performance improvement: setup signal notify in a new go routine

LGTMs: kolyshkin cyphar
2025-03-02 02:47:28 +11:00
lifubang d92dd22611 performance improvement: setup signal notify in a new go routine
There is a big loop(at least 65 times) in `signal.Notify`, it costs as much
time as `runc init`, so we can call it in parallel ro reduce the container
start time. In a general test, it can be reduced about 38.70%.

Signed-off-by: lifubang <lifubang@acmcoder.com>
(cyphar: move signal channel definition inside goroutine)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-03-01 23:46:25 +11:00
Aleksa Sarai 202ca99fae merge #4655 into opencontainers/runc:main
Kir Kolyshkin (1):
  CHANGELOG: fwd port 1.2.1 to 1.2.5 changes

LGTMs: lifubang cyphar
2025-03-01 21:38:19 +11:00
Aleksa Sarai b0a21af4b1 merge #4638 into opencontainers/runc:main
Kir Kolyshkin (1):
  Switch to opencontainers/cgroups

LGTMs: lifubang cyphar
2025-03-01 21:37:27 +11:00
Kir Kolyshkin a75076b4a4 Switch to opencontainers/cgroups
This removes libcontainer/cgroups packages and starts
using those from github.com/opencontainers/cgroups repo.

Mostly generated by:

  git rm -f libcontainer/cgroups

  find . -type f -name "*.go" -exec sed -i \
    's|github.com/opencontainers/runc/libcontainer/cgroups|github.com/opencontainers/cgroups|g' \
    {} +

  go get github.com/opencontainers/cgroups@v0.0.1
  make vendor
  gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-02-28 15:20:33 -08:00
Kir Kolyshkin 6e01e85054 CHANGELOG: fwd port 1.2.1 to 1.2.5 changes
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-02-28 11:40:56 -08:00
Kir Kolyshkin 85ba66f059 Merge pull request #4653 from opencontainers/dependabot/go_modules/github.com/opencontainers/runtime-spec-1.2.1
build(deps): bump github.com/opencontainers/runtime-spec from 1.2.0 to 1.2.1
2025-02-28 11:24:49 -08:00
dependabot[bot] 537a2276bb build(deps): bump github.com/opencontainers/runtime-spec
Bumps [github.com/opencontainers/runtime-spec](https://github.com/opencontainers/runtime-spec) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/opencontainers/runtime-spec/releases)
- [Changelog](https://github.com/opencontainers/runtime-spec/blob/main/ChangeLog)
- [Commits](https://github.com/opencontainers/runtime-spec/compare/v1.2.0...v1.2.1)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runtime-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-28 04:52:38 +00:00
Rodrigo Campos 8c72dfae65 Merge pull request #4627 from beam-cloud/main
Add skip-in-flight and link-remap criu options for checkpoint and restore
2025-02-26 06:06:26 -03:00
Rodrigo Campos 352c8d40ac Merge pull request #4636 from lifubang/fix-exec-timens
libct: don't send config to nsexec when joining an existing timens
2025-02-26 05:53:29 -03:00
Aleksa Sarai cfb643e02b merge #4641 into opencontainers/runc:main
Tomasz Duda (1):
  exeseal: do not use F_SEAL_FUTURE_WRITE

LGTMs: kolyshkin cyphar
2025-02-26 16:56:39 +11:00
Tomasz Duda c43ea7d629 exeseal: do not use F_SEAL_FUTURE_WRITE
Prior to kernel Linux 5.5, F_SEAL_FUTURE_WRITE has a bug which maps
memory as shared between processes even if it is set as private. See
kernel commit 05d351102dbe ("mm, memfd: fix COW issue on MAP_PRIVATE and
F_SEAL_FUTURE_WRITE mappings") for more details.

According to the fcntl(2) man pages, F_SEAL_WRITE is enough:

> Furthermore, trying to create new shared, writable memory-mappings via
> mmap(2) will also fail with EPERM.
>
> Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails
> with EBUSY if any writable, shared mapping exists. Such mappings must
> be unmapped before you can add this seal.

F_SEAL_FUTURE_WRITE only makes sense if a read-write shared mapping in
one process should be read-only in another process. This is not case for
runc, especially not for the /proc/self/exe we are protecting.

Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
(cyphar: improve the comment regarding F_SEAL_FUTURE_WRITE)
(cyphar: improve commit message)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-02-26 16:40:34 +11:00
Daniel Levi-Minzi 1d047e44ed expose criu options for link remap and skip in flight
Signed-off-by: Daniel Levi-Minzi <dleviminzi@gmail.com>
2025-02-25 10:35:31 -05:00
Kir Kolyshkin e0e22d33ea Merge pull request #4643 from cyphar/dmz-rename
libcontainer: rename dmz -> exeseal
2025-02-24 21:42:27 -08:00
Aleksa Sarai 58a599d28a merge #4593 into opencontainers/runc:main
Kir Kolyshkin (1):
  tests/int: add hooks argv[0] test

LGTMs: rata cyphar
2025-02-25 13:54:46 +11:00
Aleksa Sarai 559bd4ebdf libcontainer: rename dmz -> exeseal
The "dmz" name was originally used because the libcontainer/dmz package
housed the runc-dmz binary, but since we removed it in commit
871057d863 ("drop runc-dmz solution according to overlay solution")
the name is an anachronism and we should just give it a more
self-explanatory name.

So, call it libcontainer/exeseal because the purpose of the package is
to provide tools to seal /proc/self/exe against attackers.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-02-25 13:46:05 +11:00
Aleksa Sarai ef9830a0bf merge #4513 into opencontainers/runc:main
Tomasz Duda (1):
  support cgroup v1 mounted with noprefix

LGTMs: kolyshkin cyphar
2025-02-25 13:21:49 +11:00
lfbzhm 5f8abe5754 Merge pull request #4637 from mirendev/evanphx/b-eintr
Retry direct unix package calls if observing EINTR
2025-02-25 08:24:20 +08:00
lfbzhm 7ee017cf04 Merge pull request #4633 from kolyshkin/libct-cg-sep
libct/cg: eliminate remaining libct deps
2025-02-25 08:19:00 +08:00
lifubang ad09197e41 libct: don't send config to nsexec when joining an existing timens
We should configure the process's timens offset only when we need to
create new time namespace, we shouldn't do it if we are joining an
existing time namespace. (#4635)

Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-02-22 16:42:33 +00:00