Commit Graph

7438 Commits

Author SHA1 Message Date
Kir Kolyshkin 80da60e12d runc update: support per-device weight and iops
This support was missing from runc, and thus the example from the
podman-update wasn't working.

To fix, introduce a function to either update or insert new weights and iops.

Add integration tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 7696402dac)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-10-15 23:17:02 -07:00
Kir Kolyshkin 7cb4b1878f Merge pull request #4942 from lifubang/backport-1.3-4934-4917-4937
[1.3] ci: backport #4934 #4917 #4937
2025-10-15 23:16:29 -07:00
Kir Kolyshkin 1c78b1ff02 ci: only run lint-extra job on PRs to main
All the new code appears in main (not in the release branches),
and we only want extra linter rules to apply to new code.

Disable lint-extra job if the PR is not to the main branch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 1c4dba693f)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-10-16 04:56:07 +00:00
Kir Kolyshkin 1e425cc71e ci: bump golangci-lint to v2.5
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 2aea8617ea)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-10-16 04:55:48 +00:00
Kir Kolyshkin 72e673cf13 all: format sources with gofumpt v0.9.1
Since gofumpt v0.9.0 there's a new formatting rule to "clothe" any naked
returns.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b2f8a74de5)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-10-16 04:55:08 +00:00
Akihiro Suda ccd2336ac6 CI: remove deprecated lima-vm/lima-actions/ssh
`lima-vm/lima-actions/ssh` is now merged into
`lima-vm/lima-actions/setup`.

https://github.com/lima-vm/lima-actions/releases/tag/v1.1.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit c0e6f42427)
Signed-off-by: lifubang <lifubang@acmcoder.com>
2025-10-16 04:54:54 +00:00
Kir Kolyshkin dc035c597e Merge pull request #4906 from kolyshkin/1.3.2
[1.3] Release v1.3.2
2025-10-02 19:06:54 -07:00
Kir Kolyshkin 2fc3853e0d VERSION: back to development
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-10-01 16:59:58 -07:00
Kir Kolyshkin aeabe4e711 VERSION: release v1.3.2
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
v1.3.2
2025-10-01 16:59:28 -07:00
Aleksa Sarai e0b5e1e242 merge #4897 into opencontainers/runc:release-1.3
(Backported by Jared Ledvina.)

dependabot[bot]:
  build(deps): bump github.com/opencontainers/cgroups from 0.0.3 to 0.0.4

Kir Kolyshkin (4):
  deps: bump cgroups to v0.0.3, fix tests
  libct: State: ensure Resources is not nil
  deps: bump opencontainers/cgroups to v0.0.2
  tests/int: simplify using check_cpu_quota

LGTMs: kolyshkin cyphar
2025-09-25 17:13:51 +10:00
dependabot[bot] 2845c532f9 build(deps): bump github.com/opencontainers/cgroups from 0.0.3 to 0.0.4
Bumps [github.com/opencontainers/cgroups](https://github.com/opencontainers/cgroups) from 0.0.3 to 0.0.4.
- [Release notes](https://github.com/opencontainers/cgroups/releases)
- [Changelog](https://github.com/opencontainers/cgroups/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/cgroups/compare/v0.0.3...v0.0.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-24 17:04:09 -04:00
Kir Kolyshkin 3764d6e888 deps: bump cgroups to v0.0.3, fix tests
For changelog, see https://github.com/opencontainers/cgroups/releases/tag/v0.0.3

This fixes two runc issues:

1. JSON incompatibility introduced in cgroups v0.0.2 (see
   https://github.com/opencontainers/cgroups/pull/22).

2. Bad CPU shares to CPU weight conversion (see
   https://github.com/opencontainers/runc/issues/4772).

Due to item 2, modify some tests accordingly.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-09-23 13:12:41 -04:00
Kir Kolyshkin e34f6438e9 libct: State: ensure Resources is not nil
Since opencontainers/cgroups v0.0.2 (commit b206a015), all stuct
Resources fields are annotated with "omitempty" attribute.
As a result, the loaded configuration may have Resources == nil.

It is totally OK (rootless containers may have no resources configured)
except since commit 6c5441e5, cgroup v1 fs manager requires Resources to
be set in the call to NewManager (this is a cgroup v1 deficiency,
or maybe our implementation deficiency, or both).

To work around this, let's add code to ensure Resources is never nil
after loading from state.json.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-09-23 13:11:53 -04:00
Kir Kolyshkin f5e8c63fdc deps: bump opencontainers/cgroups to v0.0.2
For changes, see https://github.com/opencontainers/cgroups/releases/tag/v0.0.2

Fix integration tests according to changes in [1] (now the CPU quota value set
is rounded the same way systemd does it).

[1]: https://github.com/opencontainers/cgroups/pull/4
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-09-23 13:11:26 -04:00
Kir Kolyshkin eb29c8ddeb tests/int: simplify using check_cpu_quota
Instead of providing systemd CPU quota value (CPUQuotaPerSec),
calculate it based on how opencontainers/cgroups/systemd handles
it (see addCPUQuota).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-09-23 13:11:19 -04:00
Rodrigo Campos df25d7ccc6 Merge pull request #4895 from rata/64k-alignment-v1.3
[1.3] tests/int/cgroups: Use 64K aligned limits for memory.max
2025-09-18 00:50:25 -03:00
donettom-1 6fb80542cb tests/int/cgroups: Use 64K aligned limits for memory.max
When a non–page-aligned value is written to memory.max, the kernel aligns it
down to the nearest page boundary. On systems with a page size greater
than 4K (e.g., 64K), this caused failures because the configured
memory.max value was not 64K aligned.

This patch fixes the issue by explicitly aligning the memory.max value
to 64K. Since 64K is also a multiple of 4K, the value is correctly
aligned on both 4K and 64K page size systems.

However, this approach will still fail on systems where the hardcoded
memory.max value is not aligned to the system page size.

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

Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
Signed-off-by: Donet Tom <donettom@linux.ibm.com>
(cherry picked from commit 830c479ae2)
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-09-17 09:14:48 +02:00
Aleksa Sarai 799d52dab5 merge #4880 into opencontainers/runc:release-1.3
Aleksa Sarai (2):
  VERSION: back to development
  VERSION: release v1.3.1

LGTMs: rata kolyshkin AkihiroSuda
2025-09-05 01:24:37 +10:00
Aleksa Sarai a0dfeebeb0 VERSION: back to development
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-09-04 17:53:20 +10:00
Aleksa Sarai e6457afc48 VERSION: release v1.3.1
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.3.1
2025-09-04 17:53:19 +10:00
lfbzhm 21fbc472e3 Merge pull request #4871 from kolyshkin/1.3-4765
[1.3] Refactor/improve prepareCriuRestoreMounts
2025-08-28 12:48:20 +08:00
Kir Kolyshkin 02c4128288 criu: simplify isOnTmpfs check in prepareCriuRestoreMounts
Instead of generating a list of tmpfs mount and have a special function
to check whether the path is in the list, let's go over the list of
mounts directly. This simplifies the code and improves readability.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ce3cd4234c)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-08-28 12:28:32 +08:00
Kir Kolyshkin 69a3439c31 criu: inline makeCriuRestoreMountpoints
Since its code is now trivial, and it is only called from a single
place, it does not make sense to have it as a separate function.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit f91fbd34d9)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-08-28 12:28:32 +08:00
Kir Kolyshkin a97c49f96e criu: ignore cgroup early in prepareCriuRestoreMounts
It makes sense to ignore cgroup mounts much early in the code,
saving some time on unnecessary operations.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b8aa5481db)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-08-28 12:28:32 +08:00
Kir Kolyshkin 017d6b693f criu: improve prepareCriuRestoreMounts
1. Replace the big "if !" block with the if block and continue,
   simplifying the code flow.

2. Move comments closer to the code, improving readability.

This commit is best reviewed with --ignore-all-space or similar.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 0c93d41c65)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-08-28 12:28:32 +08:00
lfbzhm efcfc5d9cb Merge pull request #4865 from cyphar/1.3-reset-cpu-affinity
[1.3] libct: reset CPU affinity by default
2025-08-28 12:28:02 +08:00
Aleksa Sarai 9a79ff4793 [1.3] libct: reset CPU affinity by default
In certain deployments, it's possible for runc to be spawned by a
process with a restrictive cpumask (such as from a systemd unit with
CPUAffinity=... configured) which will be inherited by runc and thus the
container process by default.

The cpuset cgroup used to reconfigure the cpumask automatically for
joining processes, but kcommit da019032819a ("sched: Enforce user
requested affinity") changed this behaviour in Linux 6.2.

The solution is to try to emulate the expected behaviour by resetting
our cpumask to correspond with the configured cpuset (in the case of
"runc exec", if the user did not configure an alternative one). Normally
we would have to parse /proc/stat and /sys/fs/cgroup, but luckily
sched_setaffinity(2) will transparently convert an all-set cpumask (even
if it has more entries than the number of CPUs on the system) to the
correct value for our usecase.

For some reason, in our CI it seems that rootless --systemd-cgroup
results in the cpuset (presumably temporarily?) being configured such
that sched_setaffinity(2) will allow the full set of CPUs. For this
particular case, all we care about is that it is different to the
original set, so include some special-casing (but we should probably
investigate this further...).

Reported-by: ningmingxiao <ning.mingxiao@zte.com.cn>
Reported-by: Martin Sivak <msivak@redhat.com>
Reported-by: Peter Hunt <pehunt@redhat.com>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(Cherry-pick of commit 121192ade6c55f949d32ba486219e2b1d86898b2.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-28 10:57:05 +10:00
Aleksa Sarai ae7eefdd6a [1.3] tests: add RUNC_CMDLINE for tests incompatible with functions
Sometimes we need to run runc through some wrapper (like nohup), but
because "__runc" and "runc" are bash functions in our test suite this
doesn't work trivially -- and you cannot just pass "$RUNC" because you
you need to set --root for rootless tests.

So create a setup_runc_cmdline helper which sets $RUNC_CMDLINE to the
beginning cmdline used by __runc (and switch __runc to use that).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(Cherry-pick of commit d1f6acfab06e6f5eb15b7edfaa704f50907907b1.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-28 10:57:03 +10:00
Aleksa Sarai c0ba3d6432 [1.3] tests: add sane_run helper
"runc" was a special wrapper around bats's "run" which output some very
useful diagnostic information to the bats log, but this was not usable
for other commands. So let's make it a more generic helper that we can
use for other commands.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(Cherry-pick of commit ea385de40c9a006737399bc72918a19e5d038736.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-28 10:56:58 +10:00
lfbzhm 1a57c7f5f4 Merge pull request #4866 from cyphar/1.3-gha-arm
[1.3] CI: switch to GHA for arm
2025-08-27 18:25:36 +08:00
Kir Kolyshkin 3a6335ae00 [1.3] Switch to packaged criu on arm
The issue on arm [1] is now fixed, so let's get back to using the
packaged criu version for most of the CI matrix.

This reverts commit 105674844e
("ci: use criu built from source on gha arm").

[1]: https://github.com/checkpoint-restore/criu/issues/2709

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(Cherry-picked from commit 96f4a90a6b1ca9e3f2011ebaeffb7dc52db2ca32.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-27 14:27:31 +10:00
Kir Kolyshkin 7cd66cf04c [1.3] ci: use criu built from source on gha arm
Currently, criu package from opensuse build farm times out on GHA arm,
so let's only use criu-dev (i.e. compiled from source on CI machine).

Once this is fixed, this patch can be reverted.

Related to criu issue 2709.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(Cherry-picked from commit 105674844eaaf24bf14135ef0c64703e511882ab.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-27 14:27:04 +10:00
Kir Kolyshkin d1bfc37d68 [1.3] CI: switch to GHA for arm
Since GHA now provides ARM, we can switch away from actuated.

Many thanks to @alexellis (@self-actuated) for being the sponsor of this
project.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(Cherry-picked from commit 1cf096803abb770c414ce0a1e2e0be283b09001d.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-08-27 14:26:30 +10:00
Kir Kolyshkin 81693c22ec Merge pull request #4833 from marquiz/release-1.3
[release-1.3] runc update: don't lose intelRdt state
2025-08-04 16:54:03 -07:00
Markus Lehtonen 765cd9dcfd runc update: don't lose intelRdt state
Prevent --l3-cache-schema from clearing the intel_rdt.memBwSchema state
and --mem-bw-schema clearing l3_cache_schema, respectively.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
(cherry picked from commit 57b6a317bb)
2025-08-01 16:58:14 +03:00
Kir Kolyshkin 3e72ae4d12 Merge pull request #4819 from cyphar/1.3-proc-net-dev-overmount
[1.3] rootfs: remove /proc/net/dev from allowed overmount list
2025-07-25 20:43:57 -07:00
Aleksa Sarai 3ac9e16562 [1.3] rootfs: remove /proc/net/dev from allowed overmount list
This was added in 2ee9cbbd12 ("It's /proc/stat, not /proc/stats") with
no actual justification, and doesn't really make much sense on further
inspection:

 * /proc/net is a symlink to "self/net", which means that /proc/net/dev
   is a per-process file, and so overmounting it would only affect pid1.
   Any other program that cares about /proc/net/dev would see their own
   process's configuration, and unprivileged processes wouldn't be able
   to see /proc/1/... data anyway.

   In addition, the fact that this is a symlink means that runc will
   deny the overmount because /proc/1/net/dev is not in the proc
   overmount allowlist. This means that this has not worked for many
   years, and probably never worked in the first place.

 * /proc/self/net is already namespaced with network namespaces, so the
   primary argument for allowing /proc overmounts (lxcfs-like masking of
   procfs files to emulate namespacing for files that are not properly
   namespaced for containers -- such as /proc/cpuinfo) is moot.

   It goes without saying that lxcfs has never overmounted
   /proc/self/net/... files, so the general "because lxcfs"
   justification doesn't hold water either.

 * The kernel has slowly been moving towards blocking overmounts in
   /proc/self/. Linux 6.12 blocked overmounts for fd, fdinfo, and
   map_files; future Linux versions will probably end up blocking
   everything under /proc/self/.

Fixes: 2ee9cbbd12 ("It's /proc/stat, not /proc/stats")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(cherry-picked from commit 3620185d06b79da836559b75161027c6273fff7b.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-07-25 19:18:06 +10:00
Rodrigo Campos e6ab59dc12 Merge pull request #4810 from kolyshkin/1.3-4806
[1.3] tests/int/cgroups.bats: exclude dmem controller
2025-07-16 06:51:01 -03:00
Kir Kolyshkin 0f13e3f73b tests/int/cgroups.bats: exclude dmem controller
The dmem controller is added into kernel v6.13 and is now enabled in
Fedora 42 kernels. Yet, systemd is not aware of dmem.

This fixes the test case failure on Fedora.

For the initial test case, see commit 27515719.

For earlier commits similar to this one, see
commits 601cf582, 05272718, e83ca519.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b3432118ed)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-07-15 11:14:00 -07:00
lfbzhm d297cd5269 Merge pull request #4799 from astrawind/seccomp-agent-conn-leak-13
[1.3] libcontainer: close seccomp agent connection to prevent resource leaks
2025-07-04 22:54:52 +08:00
Pavel Liubimov ce4ad9922b libcontainer: close seccomp agent connection to prevent resource leaks
Add missing defer conn.Close().

Signed-off-by: Pavel Liubimov <prlyubimov@gmail.com>
(cherry picked from commit aa0e7989c4)
Signed-off-by: Pavel Liubimov <prlyubimov@gmail.com>
2025-07-04 00:04:53 +03:00
Akihiro Suda 4b09b7d1d7 Merge pull request #4793 from HirazawaUi/cherry-pick-4757
[release-1.3] Preventing containers from being unable to be deleted
2025-06-26 06:07:56 +09:00
HirazawaUi 2ff7959434 Preventing containers from being unable to be deleted
Signed-off-by: HirazawaUi <695097494plus@gmail.com>
(cherry picked from commit e5a74679b32b32a7670f2a19c99974d96f1585a8)
Signed-off-by: HirazawaUi <695097494plus@gmail.com>
2025-06-22 22:32:06 +08:00
lfbzhm e863512286 Merge pull request #4789 from kolyshkin/1.3-4724
[1.3] fix rootfs propagation mode to shared / unbindable
2025-06-20 17:19:27 +08:00
Yusuke Sakurai c682547894 fix rootfs propagation mode
Signed-off-by: Yusuke Sakurai <yusuke.sakurai@3-shake.com>
(cherry picked from commit 04be81b6a3)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-06-20 16:52:01 +08:00
Rodrigo Campos 97ef7dbb0d Merge pull request #4788 from kolyshkin/1.3-4784
[1.3] cgroup separation followup
2025-06-20 05:40:35 -03:00
Kir Kolyshkin 15dc7b516e libct/configs: stop using deprecated id
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit d22a42113d)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-06-19 10:37:52 -07:00
Kir Kolyshkin af614c94bd libct/configs: fix/improve deprecation notices
The per-file deprecation in cgroup_deprecated.go is not working,
let's replace it.

Link to Hooks.Run in Hook.Run deprecation notice.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit b25bcaa8b3)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-06-19 10:35:21 -07:00
Kir Kolyshkin daada5e850 libct/configs: add package docstring
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit a10d338eb2)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-06-19 10:35:21 -07:00
lfbzhm 39b6faefb6 Merge pull request #4763 from kolyshkin/1.3-sched
[1.3] ci fixes + support for scheduled ci jobs
2025-05-10 19:39:05 +08:00