Commit Graph

6443 Commits

Author SHA1 Message Date
lfbzhm caa6e523f2 Merge pull request #3900 from kolyshkin/psi
libct/cg/stats: support PSI for cgroup v2
2023-07-14 09:06:31 +08:00
Akihiro Suda 05669c8aba Merge pull request #3929 from opencontainers/dependabot/go_modules/github.com/cilium/ebpf-0.11.0
build(deps): bump github.com/cilium/ebpf from 0.10.0 to 0.11.0
2023-07-11 10:55:12 +08:00
dependabot[bot] 83418f8878 build(deps): bump github.com/cilium/ebpf from 0.10.0 to 0.11.0
Bumps [github.com/cilium/ebpf](https://github.com/cilium/ebpf) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/cilium/ebpf/releases)
- [Commits](https://github.com/cilium/ebpf/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/cilium/ebpf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 01:40:04 +00:00
Akihiro Suda 3e2c42abe2 Merge pull request #3928 from opencontainers/dependabot/go_modules/golang.org/x/net-0.12.0
build(deps): bump golang.org/x/net from 0.11.0 to 0.12.0
2023-07-11 09:39:19 +08:00
dependabot[bot] 2c844977d4 build(deps): bump golang.org/x/net from 0.11.0 to 0.12.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/net/compare/v0.11.0...v0.12.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-08 23:14:46 +08:00
Aleksa Sarai 628256245e merge pr #3924 into opencontainers/runc:main
Kir Kolyshkin (1):
  MAINTAINERS: add Li Fu Bang

LGTMs: kolyshkin AkihiroSuda cyphar hqhq mrunalp crosbymichael
Vote: +6 -0 *2
Closes #3924
2023-07-07 10:18:55 +10:00
Akihiro Suda a1d47f0171 Merge pull request #3927 from opencontainers/dependabot/go_modules/golang.org/x/sys-0.10.0
build(deps): bump golang.org/x/sys from 0.9.0 to 0.10.0
2023-07-06 22:41:10 +08:00
Mrunal Patel 369ad5a503 Merge pull request #3888 from kolyshkin/reset-failed
runc delete: call systemd's reset-failed
2023-07-06 00:09:25 -04:00
dependabot[bot] 45c75ac7ed build(deps): bump golang.org/x/sys from 0.9.0 to 0.10.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 04:35:31 +00:00
Aleksa Sarai 35eff7cdb2 merge pr #3599 into opencontainers/runc:main
Cory Snider (5):
  libct/nsenter: namespace the bindfd shuffle
  libct/nsenter: set FD_CLOEXEC on received fd
  libct/nsenter: refactor ipc funcs for reusability
  libct/nsenter: annotate write_log() prototype
  chore(libct/nsenter): extract utility code

LGTMs: AkihiroSuda kolyshkin cyphar
Closes #3599
2023-07-04 19:49:47 +10:00
Cory Snider 017d6996c0 libct/nsenter: namespace the bindfd shuffle
Processes can watch /proc/self/mounts or /mountinfo, and the kernel
will notify them whenever the namespace's mount table is modified. The
notified process still needs to read and parse the mountinfo to
determine what changed once notified. Many such processes, including
udisksd and SystemD < v248, make no attempt to rate-limit their
mountinfo notifications. This tends to not be a problem on many systems,
where mount tables are small and mounting and unmounting is uncommon.
Every runC exec which successfully uses the try_bindfd container-escape
mitigation performs two mount()s and one umount() in the host's mount
namespace, causing any mount-watching processes to wake up and parse the
mountinfo file three times in a row. Consequently, using 'exec' health
checks on containers has a larger-than-expected impact on system load
when such mount-watching daemons are running. Furthermore, the size of
the mount table in the host's mount namespace tends to be proportional
to the number of OCI containers as a unique mount is required for the
rootfs of each container. Therefore, on systems with mount-watching
processes, the system load increases *quadratically* with the number of
running containers which use health checks!

Prevent runC from incidentally modifying the host's mount namespace for
container-escape mitigations by setting up the mitigation in a temporary
mount namespace.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-04 17:56:25 +10:00
Cory Snider 3b191ff710 libct/nsenter: set FD_CLOEXEC on received fd
Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-04 17:56:25 +10:00
Cory Snider 8f67178139 libct/nsenter: refactor ipc funcs for reusability
Modify receive_fd() and send_fd() so they can be more readily reused in
cloned_binary.c. Change receive_fd() to have a single responsibility:
receiving and returning a single file descriptor over a UNIX domain
socket. Make send_fd() useable in precarious execution contexts such as
a clone(CLONE_VFORK|CLONE_VM) "thread" where allocating heap memory or
calling exit() would be dangerous.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-04 17:56:25 +10:00
Cory Snider 890dceeebf libct/nsenter: annotate write_log() prototype
...so the compiler can warn about mismatches between the format string
and varargs.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-04 17:56:25 +10:00
Cory Snider 35fddfd28f chore(libct/nsenter): extract utility code
...from nsexec.c so they can be used in cloned_binary.c.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-07-04 17:56:25 +10:00
Kir Kolyshkin 37732d1e7d MAINTAINERS: add Li Fu Bang
I am nominating @lifubang for the role of runc maintainer.

He provided a number of valuable contributions to runc, and demonstrated
both deep technical expertise and the long term commitment to the
project.

As noted in MAINTAINERS_GUIDE.md, we have a week to vote, and need to
get 66% of current maintainers' votes.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-30 10:50:49 -07:00
Kir Kolyshkin 164e4bc5f6 Merge pull request #3915 from opencontainers/dependabot/go_modules/google.golang.org/protobuf-1.31.0
build(deps): bump google.golang.org/protobuf from 1.30.0 to 1.31.0
2023-06-28 09:54:16 -07:00
Kir Kolyshkin ad040b1caf tests/int/delete: make sure runc delete removes failed unit
The passing run (with the fix) looks like this:

----
delete.bats
 ✓ runc delete removes failed systemd unit [4556]
   runc spec (status=0):

   runc run -d --console-socket /tmp/bats-run-B08vu1/runc.lbQwU5/tty/sock test-failed-unit (status=0):

   Warning: The unit file, source configuration file or drop-ins of runc-cgroups-integration-test-12869.scope changed on disk. Run 'systemctl daemon-reload' to reload units.
   × runc-cgroups-integration-test-12869.scope - libcontainer container integration-test-12869
        Loaded: loaded (/run/systemd/transient/runc-cgroups-integration-test-12869.scope; transient)
     Transient: yes
       Drop-In: /run/systemd/transient/runc-cgroups-integration-test-12869.scope.d
                └─50-DevicePolicy.conf, 50-DeviceAllow.conf
        Active: failed (Result: timeout) since Tue 2023-06-13 14:41:38 PDT; 751ms ago
      Duration: 2.144s
           CPU: 8ms

   Jun 13 14:41:34 kir-rhat systemd[1]: Started runc-cgroups-integration-test-12869.scope - libcontainer container integration-test-12869.
   Jun 13 14:41:37 kir-rhat systemd[1]: runc-cgroups-integration-test-12869.scope: Scope reached runtime time limit. Stopping.
   Jun 13 14:41:38 kir-rhat systemd[1]: runc-cgroups-integration-test-12869.scope: Stopping timed out. Killing.
   Jun 13 14:41:38 kir-rhat systemd[1]: runc-cgroups-integration-test-12869.scope: Killing process 1107438 (sleep) with signal SIGKILL.
   Jun 13 14:41:38 kir-rhat systemd[1]: runc-cgroups-integration-test-12869.scope: Failed with result 'timeout'.
   runc delete test-failed-unit (status=0):

   Unit runc-cgroups-integration-test-12869.scope could not be found.
----

Before the fix, the test was failing like this:

----
delete.bats
 ✗ runc delete removes failed systemd unit
   (in test file tests/integration/delete.bats, line 194)
     `run -4 systemctl status "$SD_UNIT_NAME"' failed, expected exit code 4, got 3
  ....
----

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-28 09:28:35 -07:00
Kir Kolyshkin 58a811f6aa tests/int: add/use "requires systemd_vNNN"
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-28 09:28:35 -07:00
Kir Kolyshkin 43564a7b55 runc delete: call systemd's reset-failed
runc delete is supposed to remove all the container's artefacts.
In case systemd cgroup driver is used, and the systemd unit has failed
(e.g. oom-killed), systemd won't remove the unit (that is, unless the
"CollectMode: inactive-or-failed" property is set).

Call reset-failed from manager.Destroy so the failed unit will be
removed during "runc delete".

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-28 09:28:35 -07:00
Kir Kolyshkin 91b4cd25b7 libct/cg/sd: remove logging from resetFailedUnit
Sometimes we call resetFailedUnit as a cleanup measure, and we don't
care if it fails or not. So, move error reporting to its callers, and
ignore error in cases we don't really expect it to succeed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-28 09:28:35 -07:00
Kir Kolyshkin dacb3aaa0d tests/int/cgroups: remove useless/wrong setting
There is no such thing as linux.resources.memorySwap (the mem+swap is
set as linux.resources.memory.swap).

As it is not used in this test anyway, remove it.

Fixes: 4929c05ad1
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-28 09:28:35 -07:00
Sebastiaan van Stijn e42446f7c6 Merge pull request #3912 from cpuguy83/fix_tmpfs_mode
Fix tmpfs mode opts when dir already exists
2023-06-28 16:15:28 +02:00
Sebastiaan van Stijn f9bd4a5a2f Merge pull request #3827 from kolyshkin/no-panic
libct/cg: IsCgroup2UnifiedMode: don't panic
2023-06-28 15:29:46 +02:00
Sebastiaan van Stijn 17b335a2ee Merge pull request #3902 from kolyshkin/skip-less
ci/gha: don't skip rootless+systemd on ubuntu 22.04
2023-06-28 15:28:08 +02:00
Sebastiaan van Stijn 651c044a2b Merge pull request #3889 from kolyshkin/shellcheck-0.9
ci: bump shellcheck to 0.9.0, fix new SC2016 warnings
2023-06-28 15:26:43 +02:00
Sebastiaan van Stijn aacc27b7fe Merge pull request #3852 from kolyshkin/doc-log-level
libct: document process.LogLevel field
2023-06-28 15:22:46 +02:00
Kir Kolyshkin 5cdf76719e libct/cg: IsCgroup2UnifiedMode: don't panic
Replace a panic with a warning, unless it's ENOENT and we're running in
a user namespace. In the latter case, do the same as before, i.e. report
the error but using a Debug logging level.

This prevents software that uses libcontainer from panicking in
some exotic setups.

This will also print a warning on some very old systems which does not
use /sys/fs/cgroup for cgroup mount point. My bet is such systems no
longer exist.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-27 11:29:37 -07:00
Akihiro Suda 92c71e725f Merge pull request #3804 from jiusanzhou/bugfix/skip-update-while-frozen-faield
libct/cg/sd/v1: do not update non-frozen cgroup after frozen failed.
2023-06-28 03:19:53 +09:00
Kir Kolyshkin 5e53e6592a ci: bump shellcheck to 0.9.0, fix new SC2016 warnings
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-27 08:44:21 -07:00
dependabot[bot] a57d94d3ad build(deps): bump google.golang.org/protobuf from 1.30.0 to 1.31.0
Bumps google.golang.org/protobuf from 1.30.0 to 1.31.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 04:58:59 +00:00
Brian Goff 9fa8b9de3e Fix tmpfs mode opts when dir already exists
When a directory already exists (or after a container is restarted) the
perms of the directory being mounted to were being used even when a
different permission is set on the tmpfs mount options.

This prepends the original directory perms to the mount options.
If the perms were already set in the mount opts then those perms will
win.
This eliminates the need to perform a chmod after mount entirely.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-06-26 21:53:21 +00:00
Kir Kolyshkin 1bc2999b77 Merge pull request #3913 from fish98/main
Fix checkpoints integration tests failure
2023-06-26 11:07:03 -07:00
TTFISH eb55472ee1 Fix integration tests failure when calling "ip"
Signed-off-by: TTFISH <jiongchiyu@gmail.com>
2023-06-25 17:32:23 +08:00
Kir Kolyshkin bcaee38a9a Merge pull request #3903 from opencontainers/dependabot/go_modules/golang.org/x/net-0.11.0
build(deps): bump golang.org/x/net from 0.10.0 to 0.11.0
2023-06-22 09:21:26 -07:00
dependabot[bot] a52efc1ffd build(deps): bump golang.org/x/net from 0.10.0 to 0.11.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-21 18:13:29 +00:00
Aleksa Sarai e099ffb8df merge pr #3907 into main
Kir Kolyshkin (1):
  .codespellrc: update for 2.2.5
2023-06-22 01:12:56 +10:00
Kir Kolyshkin e3627658fa .codespellrc: update for 2.2.5
Remove some old exceptions (no longer needed), add a new one
(codespell 2.2.5 flags "(mis)features" in docs/terminal.md).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-16 10:07:40 -07:00
Akihiro Suda 5cf9bb229f Merge pull request #3883 from kolyshkin/space-at-eol
ci/gha: add space-at-eol check, fix existing issues
2023-06-14 12:39:09 +09:00
Kir Kolyshkin c9209fd223 ci/gha: don't skip rootless+systemd on ubuntu 22.04
We used to skip testing rootless integration tests for systemd, because
in case of cgroup v1 it does not support user delegation.

Since we added ubuntu 22.04 to the testing matrix, we can actually test
rootless+systemd there (with the proper systemd setup).

Fixes: 953e1cc485
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-13 18:01:09 -07:00
Sebastiaan van Stijn 4f5c350513 Merge pull request #3899 from kolyshkin/fix-sd-linl
docs/systemd: fix a broken link
2023-06-14 01:12:46 +02:00
Daniel Dao 1aa7ca8046 libct/cg/stats: support PSI for cgroup v2
We read output from the following files if they exists:
- cpu.pressure
- memory.pressure
- io.pressure

Each are in format:

```
some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
```

Signed-off-by: Daniel Dao <dqminh89@gmail.com>
Co-authored-by: Sandor Szücs <sandor.szuecs@zalando.de>
Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-13 15:43:39 -07:00
Kir Kolyshkin 2f42992a34 Merge pull request #3896 from AkihiroSuda/spec-v1.1.0-rc.3
go.mod: runtime-spec v1.1.0-rc.3
2023-06-13 10:37:03 -07:00
dependabot[bot] d161491c25 Merge pull request #3901 from opencontainers/dependabot/go_modules/golang.org/x/sys-0.9.0 2023-06-13 06:49:27 +00:00
dependabot[bot] bc390b2e67 build(deps): bump golang.org/x/sys from 0.8.0 to 0.9.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/sys/compare/v0.8.0...v0.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 04:58:49 +00:00
Kir Kolyshkin 73b5dc027d docs/systemd: fix a broken link
Apparently, developer.gnome.org/documentation no longer hosts the
documentation we used to refer to. Link to docs.gtk.org instead.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-06-12 16:10:06 -07:00
Zoe 62963fef9f libct/cg/sd/v1: do not update non-frozen cgroup after frozen failed.
In code we have frozen the cgroup to avoid the processes get
an occasional "permission denied" error, while the systemd's application of device
rules is done disruptively. When the processes in the container can not
be frozen over 2 seconds (which defined in fs/freezer.go),
we still update the cgroup which resulting the container get an occasional
"permission denied" error in some cases.

Return error directly without updating cgroup, when freeze fails.

Fixes: #3803

Signed-off-by: Zoe <hi@zoe.im>
2023-06-12 10:10:04 +08:00
Akihiro Suda 0ac3376c20 go.mod: runtime-spec v1.1.0-rc.3
https://github.com/opencontainers/runtime-spec/releases/tag/v1.1.0-rc.3

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-06-10 17:19:11 +09:00
Akihiro Suda 0b9d545d02 Merge pull request #3553 from kolyshkin/moar-ci
ci/cirrus: enable some rootless tests on cs9
2023-06-10 15:40:21 +09:00
Aleksa Sarai 14456efde1 merge pr #3825
Kir Kolyshkin (7):
  libct: implement support for cgroup.kill
  runc kill: drop -a option
  libct: move killing logic to container.Signal
  libct: fix shared pidns detection
  libct: signalAllProcesses: remove child reaping
  tests/int/kill: add kill -a with host pidns test
  tests/rootless.sh: drop set -x

LGTMs: AkihiroSuda cyphar
Closes #3825
2023-06-10 14:26:06 +10:00