Commit Graph

6330 Commits

Author SHA1 Message Date
Akihiro Suda dac38522e2 Merge pull request #3812 from kolyshkin/sd-rm-race
libct: fix a race with systemd removal
2023-04-21 16:50:54 +02:00
Akihiro Suda e61ce723db Merge pull request #3834 from kolyshkin/doc-kill-a
runc-kill(8): amend the --all description
2023-04-21 16:50:09 +02:00
Kir Kolyshkin 42a109198c runc-kill(8): amend the --all description
Document the aspects of --all.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-20 18:00:02 -07:00
Kir Kolyshkin fe278b9caa libct: fix a race with systemd removal
For a previous attempt to fix that (and added test cases), see commit
9087f2e827.

Alas, it's not always working because of cgroup directory TOCTOU.

To solve this and avoid the race, add an error _after_ the operation.
Implement it as a method that ignores the error that should be ignored.
Instead of currentStatus(), use faster runType(), since we are not
interested in Paused status here.

For Processes(), remove the pre-op check, and only use it after getting
an error, making the non-error path more straightforward.

For Signal(), add a second check after getting an error. The first check
is left as is because signalAllProcesses might print a warning if the
cgroup does not exist, and we'd like to avoid that.

This should fix an occasional failure like this one:

	not ok 84 kill detached busybox
	# (in test file tests/integration/kill.bats, line 27)
	#   `[ "$status" -eq 0 ]' failed
	....
	# runc kill test_busybox KILL (status=0):
	# runc kill -a test_busybox 0 (status=1):
	# time="2023-04-04T18:24:27Z" level=error msg="lstat /sys/fs/cgroup/devices/system.slice/runc-test_busybox.scope: no such file or directory"

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-20 17:50:23 -07:00
Akihiro Suda 3a2c0c2565 Merge pull request #3824 from cyphar/release-gpgkeys
release: add runc.keyring file
2023-04-19 20:11:31 +02:00
Kir Kolyshkin fdc2515187 Merge pull request #3600 from utam0k/domainname
Implement to set a domainname
2023-04-19 10:16:34 -07:00
Aleksa Sarai 056ec0caa6 keyring: add Aleksa's <cyphar@cyphar.com> signing key
keyid C9C370B246B09F6DBCFC744C34401015D1D2D386

This is my personal signing key, which I've used to sign the vast
majority of my commits on GitHub. While I usually sign releases using my
<asarai@suse.de> signing key, it doesn't hurt to include this key too.

Ref: https://keyserver.ubuntu.com/pks/lookup?search=C9C370B246B09F6DBCFC744C34401015D1D2D386&fingerprint=on&op=index
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-04-19 13:48:22 +10:00
Aleksa Sarai 0c9c60aa18 keyring: add Aleksa's <asarai@suse.com> signing key
keyid 5F36C6C61B5460124A75F5A69E18AA267DDB8DB4

This is the signing key I have used for all previous runc releases. You
can also verify that this is the key trusted by openSUSE for all of our
releases.

Ref: https://keyserver.ubuntu.com/pks/lookup?search=5F36C6C61B5460124A75F5A69E18AA267DDB8DB4&fingerprint=on&op=index
Ref: https://build.opensuse.org/package/view_file/openSUSE:Factory/runc/runc.keyring?expand=1&rev=54
Signed-off-by: Aleksa Sarai <asarai@suse.de>
2023-04-19 13:48:17 +10:00
Aleksa Sarai 22538f896a keyring: verify runc.keyring has legitimate maintainer keys
These checks ensure that all of the keys in the runc.keyring list are
actually the keys of the specified user and that the users themselves
are actually maintainers.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-04-19 13:48:14 +10:00
Aleksa Sarai 957bccfe2f scripts: release: add verification checks for signing keys
We need to make sure the release is being signed by a key that is
actually listed as a trusted signing key, and we also need to ask the
person cutting the release whether the list of trusted keys is
acceptable.

Also add some verification checks after a release is signed to make sure
everything was signed with the correct keys.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-04-19 13:48:14 +10:00
Aleksa Sarai 872149470b release: add runc.keyring file and script
In order to allow any of the maintainers to cut releases for runc,
create a keyring file that distributions can use to verify that releases
are signed by one of the maintainers.

The format matches the gpg-offline format used by openSUSE packaging,
but it can be easily imported with "gpg --import" so any distribution
should be able to handle this keyring format wtihout issues.

Each key includes the GitHub handle of the associated user. There isn't
any way for this information to be automatically verified (outside of
using something like keybase.io) but since all changes of this file need
to be approved by maintainers this is okay for now.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-04-14 01:00:27 +10:00
utam0k d9230602e9 Implement to set a domainname
opencontainers/runtime-spec#1156

Signed-off-by: utam0k <k0ma@utam0k.jp>
2023-04-12 13:31:20 +00:00
Aleksa Sarai 11983894a8 merge #3790 into main
Kazuki Hasegawa (1):
  Fix undefined behavior. Do not accept setjmp return value as variable.

LGTMs: AkihiroSuda cyphar
Closes #3790
2023-04-12 19:48:18 +10:00
Kazuki Hasegawa 6053aea46f Fix undefined behavior.
Do not accept setjmp return value as variable.

Signed-off-by: Kazuki Hasegawa <nanasi880@gmail.com>
2023-04-12 14:27:43 +10:00
Kir Kolyshkin e42c219fea Merge pull request #3820 from kolyshkin/ubu-22.04
ci/gha: add ubuntu 22.04
2023-04-11 13:40:27 -07:00
Kir Kolyshkin 953e1cc485 ci/gha: switch to or add ubuntu 22.04
For test jobs, add ubuntu 22.04 into the matrix, so we can test of both
cgroup v1 and v2.

For validate jobs, just switch to ubuntu 22.04

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-10 10:32:02 -07:00
Mrunal Patel d8a3daacbd Merge pull request #3815 from kolyshkin/bump-bats
bump bats-core, fix some tests, use new features
2023-04-08 08:55:21 -07:00
Kir Kolyshkin 1789002048 Merge pull request #3819 from opencontainers/dependabot/go_modules/golang.org/x/net-0.9.0
build(deps): bump golang.org/x/net from 0.8.0 to 0.9.0
2023-04-07 15:44:40 -07:00
dependabot[bot] 439673d510 build(deps): bump golang.org/x/net from 0.8.0 to 0.9.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.8.0...v0.9.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-04-07 04:59:18 +00:00
Mrunal Patel 941e5924ef Merge pull request #3814 from kolyshkin/go-1.19-minor
ci/cirrus: use Go 1.19.x not 1.19
2023-04-06 14:27:14 -07:00
Kir Kolyshkin fd1a79ffc8 ci/cirrus: improve host_info
1. Do not use echo, as this results in lines like this:

	...
	echo "-----"
	-----
	...

2. Move "cat /proc/cpuinfo" to be the last one, as the output is usually
   very long.

3. Add "go version" to CentOS jobs.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-06 10:52:05 -07:00
Kir Kolyshkin 873d7bb3a3 ci/cirrus: use Go 1.19.x not 1.19
This variable is used in curl to download a go release, so we are using
the initial Go 1.19 release in Cirrus CI, not the latest Go 1.19.x
release.

From the CI perspective, it makes more sense to use the latest release.

Add some jq magic to extract the latest minor release information
from the download page, and use it.

This brings Cirrus CI jobs logic in line with all the others (GHA,
Dockerfile), where by 1.20 we actually mean "latest 1.20.x".

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-06 10:51:43 -07:00
Kir Kolyshkin 611bbacb3b libct/cg: add misc controller to v1 drivers
This is just so that the container can join the misc controller.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-05 15:49:58 -07:00
Kir Kolyshkin 9b71787be0 tests/int: fix some checks
Apparently, bash with set -e deliberately ignores non-zero return codes
from ! cmd, unless this is the last command. The workaround is to either
use "! cmd || false', "or run ! cmd". Choose the latter, and require
bash-core 1.5.0 (since this is when "run !" was added), replacing the
older check.

Alas I only learned this recently from the bash-core documentation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-05 15:22:23 -07:00
Kir Kolyshkin 9dbb9f90b9 ci: bump bats 1.3.0 -> 1.8.2
This version is already used by Cirrus CI Fedora 37 job, but other CI
jobs are still using 1.3.0.

Bump it everywhere so we can enjoy new version features and fixes.

For one thing, I noticed that new bats is reporting error location
correctly.

We will also be able to use "run !" and "run -N" commands.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-05 15:22:23 -07:00
Sebastiaan van Stijn 5726682966 Merge pull request #3813 from opencontainers/dependabot/go_modules/golang.org/x/sys-0.7.0
build(deps): bump golang.org/x/sys from 0.6.0 to 0.7.0
2023-04-05 21:01:27 +02:00
dependabot[bot] a6e95c53f4 build(deps): bump golang.org/x/sys from 0.6.0 to 0.7.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.6.0...v0.7.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-04-05 04:59:43 +00:00
Akihiro Suda 67b542bb4e Merge pull request #3810 from kolyshkin/rm-get-init-cgroup-path
libct/cg: rm GetInitCgroup[Path]
2023-04-05 10:59:37 +09:00
Akihiro Suda 1b4cf1d2ae Merge pull request #3809 from opencontainers/dependabot/github_actions/lumaxis/shellcheck-problem-matchers-2
build(deps): bump lumaxis/shellcheck-problem-matchers from 1 to 2
2023-04-05 03:26:36 +09:00
Akihiro Suda 0cab3b3dda Merge pull request #3779 from fish98/main
tests: Fix fuzzer location in oss-fuzz config
2023-04-05 03:26:04 +09:00
Kir Kolyshkin fd5debf3aa libct/cg: rm GetInitCgroup[Path]
These functions were added in ancient times, facilitating the
docker-in-docker case when cgroup namespace was not available.

As pointed out in commit 2b28b3c276, using init 1 cgroup is not
correct because it won't work in case of host PID namespace.

The last user of GetInitCgroup was removed by commit
54e20217a8. GetInitCgroupPath was never used
as far as I can see, nor was I able to find any external users.

Remove both functions. Modify the comment in libct/cg/fs.subsysPath
to not refer to GetInitCgroupPath.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-04 11:19:25 -07:00
dependabot[bot] 1034cfa826 build(deps): bump lumaxis/shellcheck-problem-matchers from 1 to 2
Bumps [lumaxis/shellcheck-problem-matchers](https://github.com/lumaxis/shellcheck-problem-matchers) from 1 to 2.
- [Release notes](https://github.com/lumaxis/shellcheck-problem-matchers/releases)
- [Commits](https://github.com/lumaxis/shellcheck-problem-matchers/compare/v1...v2)

---
updated-dependencies:
- dependency-name: lumaxis/shellcheck-problem-matchers
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-04 17:44:14 +00:00
Kir Kolyshkin cc60a390ad Merge pull request #3784 from haircommander/root-cgroup-no-init
libctr/cgroups: don't take init's cgroup into account
2023-04-04 09:34:26 -07:00
Mrunal Patel 7ba53a1526 Merge pull request #3788 from kolyshkin/systemd-cpu-idle
cg/sd: support CPUWeight=idle (aka cpu.idle=1)
2023-04-04 08:07:34 -07:00
Kir Kolyshkin ed9651bc71 libct/cg/sd: support setting cpu.idle via systemd
Systemd v252 (available in CentOS Stream 9 in our CI) added support
for setting cpu.idle (see [1]). The way it works is:
 - if CPUWeight == 0, cpu.idle is set to 1;
 - if CPUWeight != 0, cpu.idle is set to 0.

This commit implements setting cpu.idle in systemd cgroup driver via a
unit property. In case CPUIdle is set to non-zero value, the driver sets
adds CPUWeight=0 property, which will result in systemd setting cpu.idle
to 1.

Unfortunately, there's no way to set cpu.idle to 0 without also changing
the CPUWeight value, so the driver doesn't do anything if CPUIdle is
explicitly set to 0. This case is handled by the fs driver which is
always used as a followup to setting systemd unit properties.

Also, handle cpu.idle set via unified map. In case it is set to non-zero
value, add CPUWeight=0 property, and ignore cpu.weight (otherwise we'll
get two different CPUWeight properties set).

Add a unit test for new values in unified map, and an integration test case.

[1] https://github.com/systemd/systemd/pull/23299
[2] https://github.com/opencontainers/runc/issues/3786

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-03 18:25:07 -07:00
Kir Kolyshkin b5ecad7ba3 tests/int/update: test bad cpu.idle values
Values other than 1 or 0 are ignored by the kernel,
see sched_group_set_idle() in kernel/sched/fair.c

If the added test case ever fails, it means that the kernel now accepts
values other than 0 or 1, and runc needs to adopt to that.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-03 18:25:07 -07:00
Kir Kolyshkin 3ffbd4c85a tests/int: fix update cpu.idle failure on CS9
Systemd v252 (available in CentOS Stream 9 in our CI) added support
for setting cpu.idle (see [1]). The way it works is:
 - if CPUWeight == 0, cpu.idle is set to 1;
 - if CPUWeight != 0, cpu.idle is set to 0.

This behavior breaks the existing test case, as described in [2].

To fix, skip the last check in the test case in case a newer systemd
is used.

Fixes: #3786

[1] https://github.com/systemd/systemd/pull/23299
[2] https://github.com/opencontainers/runc/issues/3786

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-03 18:25:07 -07:00
Kir Kolyshkin 509b312cfb libct/cg/sd/v2: unifiedResToSystemdProps nit
In code that checks that the resource name is in the for
Using strings.SplitN is an overkill in this case, resulting in
allocations and thus garbage to collect.

Using strings.IndexByte and checking that result is not less than 1
(meaning there is a period, and it is not the first character) is
sufficient here.

Fixes: 0cb8bf67a3
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-03 18:24:47 -07:00
Kir Kolyshkin 9f2451346e Merge pull request #3782 from kolyshkin/fix-sd-start
Fix systemd cgroup driver's Apply
2023-04-03 11:27:17 -07:00
Akihiro Suda 17922e3612 Merge pull request #3800 from kolyshkin/fp-ch
CHANGELOG: forward-port 1.1.4 and 1.1.5 changes
2023-04-03 18:12:10 +09:00
Kir Kolyshkin ba618705f8 Merge pull request #3797 from kolyshkin/enter-pid
libct/cg: rm EnterPid
2023-03-31 13:01:39 -07:00
Kir Kolyshkin 82bc89cd10 runc run: refuse a non-empty cgroup
Commit d08bc0c1b3 ("runc run: warn on non-empty cgroup") introduced
a warning when a container is started in a non-empty cgroup. Such
configuration has lots of issues.

In addition to that, such configuration is not possible at all when
using the systemd cgroup driver.

As planned, let's promote this warning to an error, and fix the test
case accordingly.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:55:39 -07:00
Kir Kolyshkin 1d18743f9e libct/cg/sd: reset-failed and retry startUnit on UnitExists
In case a systemd unit fails (for example, timed out or OOM-killed),
systemd keeps the unit. This prevents starting a new container with
the same systemd unit name.

The fix is to call reset-failed in case UnitExists error is returned,
and retry once.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:55:39 -07:00
Kir Kolyshkin c253342061 libct/cg/sd: ignore UnitExists only for Apply(-1)
Commit d223e2adae ("Ignore error when starting transient unit
that already exists" modified the code handling errors from startUnit
to ignore UnitExists error.

Apparently it was done so that kubelet can create the same pod slice
over and over without hitting an error (see [1]).

While it works for a pod slice to ensure it exists, it is a gross bug
to ignore UnitExists when creating a container. In this case, the
container init PID won't be added to the systemd unit (and to the
required cgroup), and as a result the container will successfully
run in a current user cgroup, without any cgroup limits applied.

So, fix the code to only ignore UnitExists if we're not adding a process
to the systemd unit. This way, kubelet will keep working as is, but
runc will refuse to create containers which are not placed into a
requested cgroup.

[1] https://github.com/opencontainers/runc/pull/1124

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:55:39 -07:00
Kir Kolyshkin c6e8cb7926 libct/cg/sd: refactor startUnit
Move error handling earlier, removing "if err == nil" block.

No change of logic.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:55:39 -07:00
Kir Kolyshkin 9f32ce6a2d CHANGELOG: forward-port 1.1.4 and 1.1.5 changes
...from the tip of release-1.1 branch (commit 060a61c69d).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:46:53 -07:00
Kir Kolyshkin 73acc77be5 libct/cg: rm EnterPid
Since commit 39914db679 this function is not used by runc (see
that commit to learn why this function is not that good).

I was not able to find any external users either.

Since it's not a good function, with no users, and it is rather trivial,
let's remove it right away (rather than mark as deprecated).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-31 13:33:00 +11:00
Kir Kolyshkin 4ff4904603 Makefile: add verify-changelog as release dependency
... as a way to maybe catch some CHANGELOG.md bugs at the last moment.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 54cfb25d69)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:11:31 -07:00
Kir Kolyshkin b2fc0a589c verify-changelog: allow non-ASCII
Previously (see commit 91fa032da4) we found a few issues
using this check, but apparently the CHANGELOG.md is in UTF-8, and
the recently added quote is breaking this, so remove.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 7b3ac330f7)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-03-30 19:11:11 -07:00
Kir Kolyshkin 8edf478e34 Merge pull request #3798 from kolyshkin/fix-mount-test
Fix mount test
2023-03-30 18:32:27 -07:00