Commit Graph

7001 Commits

Author SHA1 Message Date
lifubang 45471bc945 VERSION: release v1.2.0-rc.3
Signed-off-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.2.0-rc.3
2024-09-03 11:29:51 +10:00
Aleksa Sarai 6c24b2e83e changelog: update to include 1.1.14 notes
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-09-03 11:29:21 +10:00
Aleksa Sarai 9e9fdd815a Merge commit from fork
rootfs: try to scope MkdirAll to stay inside the rootfs
2024-09-03 10:55:23 +10:00
Aleksa Sarai 63c2908164 rootfs: try to scope MkdirAll to stay inside the rootfs
While we use SecureJoin to try to make all of our target paths inside
the container safe, SecureJoin is not safe against an attacker than can
change the path after we "resolve" it.

os.MkdirAll can inadvertently follow symlinks and thus an attacker could
end up tricking runc into creating empty directories on the host (note
that the container doesn't get access to these directories, and the host
just sees empty directories). However, this could potentially cause DoS
issues by (for instance) creating a directory in a conf.d directory for
a daemon that doesn't handle subdirectories properly.

In addition, the handling for creating file bind-mounts did a plain
open(O_CREAT) on the SecureJoin'd path, which is even more obviously
unsafe (luckily we didn't use O_TRUNC, or this bug could've allowed an
attacker to cause data loss...). Regardless of the symlink issue,
opening an untrusted file could result in a DoS if the file is a hung
tty or some other "nasty" file. We can use mknodat to safely create a
regular file without opening anything anyway (O_CREAT|O_EXCL would also
work but it makes the logic a bit more complicated, and we don't want to
open the file for any particular reason anyway).

libpathrs[1] is the long-term solution for these kinds of problems, but
for now we can patch this particular issue by creating a more restricted
MkdirAll that refuses to resolve symlinks and does the creation using
file descriptors. This is loosely based on a more secure version that
filepath-securejoin now has[2] and will be added to libpathrs soon[3].

[1]: https://github.com/openSUSE/libpathrs
[2]: https://github.com/cyphar/filepath-securejoin/releases/tag/v0.3.0
[3]: https://github.com/openSUSE/libpathrs/issues/10

Fixes: CVE-2024-45310
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-09-03 02:34:13 +10:00
Akihiro Suda 346b818dad Merge pull request #4380 from rata/makefile-no-envs
Makefile: Don't read COMMIT, BUILDTAGS, EXTRA_BUILDTAGS from env vars
2024-08-24 23:46:59 +09:00
Rodrigo Campos 767bc0089c Makefile: Don't read COMMIT, BUILDTAG, EXTRA_BUILDTAGS from env vars
We recently switched VERSION to be read from env vars (#4270). This
broke several projects, as they were building runc and using a `VERSION`
env var for, e.g. the containerd version.

When fixing that in #4370, we discussed to consider doing the same for
these variables too
(https://github.com/opencontainers/runc/pull/4370#pullrequestreview-2240030944).

Let's stop reading them from env vars, as it is very easy to do it by
mistake (e.g. compile runc and define a COMMIT env var, not to override
the commit shown in `runc --version`) and users that want can still
override them if they want to. For example, with:

	make EXTRA_BUILDTAGS=runc_nodmz

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-08-24 14:50:45 +02:00
Akihiro Suda a41b62a5e1 Merge pull request #4376 from kolyshkin/simplify-branch-protection
ci/gha: add all-done jobs
2024-08-22 10:59:47 +09:00
Kir Kolyshkin 2cd24a4dae ci/gha: add all-done jobs
The sole reason is to simplify branch protection rules,
requiring just these to be passed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-21 17:00:59 -07:00
Rodrigo Campos 41831e7635 Merge pull request #4377 from AkihiroSuda/distro-should-not-install-recvtty-etc
mv contrib/cmd tests/cmd (except memfd-bind)
2024-08-21 11:38:48 +02:00
Kir Kolyshkin 376e875fdd Merge pull request #4370 from rata/main
Revert "allow overriding VERSION value in Makefile" and add EXTRA_VERSION
2024-08-16 03:30:13 -07:00
Rodrigo Campos cc2078ccdd Makefile: Add EXTRA_VERSION
Add this new make variable so users can specify build information
without modifying the runc version nor the source code.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-08-15 18:06:03 +02:00
Akihiro Suda f76489f0af mv contrib/cmd tests/cmd (except memfd-bind)
The following commands are moved from `contrib/cmd` to `tests/cmd`:
- fs-idmap
- pidfd-kill
- recvtty
- remap-rootfs
- sd-helper
- seccompagent

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-16 00:55:48 +09:00
Rodrigo Campos f4cc3d8313 Revert "allow overriding VERSION value in Makefile"
This reverts commit 9d9273c926.

This commit broke the build for several other projects (see comments
here: https://github.com/opencontainers/runc/pull/4270, after the merge)
and we don't really need this to be able to set the version without
changing the file.

With this commit reverted, we can still run:

	make VERSION="1.2.3"

and it just works. It doesn't take it from an env variable, but that is
what broke all the other projects (VERSION is just too generic as an env
var, especially for a project like runc that is embedded in many
others).

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-08-15 11:09:14 +02:00
lfbzhm 0377d50458 Merge pull request #4360 from kolyshkin/go123
Add Go 1.23, drop 1.21
2024-08-15 12:02:04 +08:00
Kir Kolyshkin 606257c6e1 Bump golangci-lint to v1.60, fix new warnings
The warnings fixed were:

libcontainer/configs/config_test.go:205:12: printf: non-constant format string in call to (*testing.common).Errorf (govet)
		t.Errorf(fmt.Sprintf("Expected error to not occur but it was %+v", err))
		         ^
libcontainer/cgroups/fs/blkio_test.go:481:13: printf: non-constant format string in call to (*testing.common).Errorf (govet)
			t.Errorf(fmt.Sprintf("test case '%s' failed unexpectedly: %s", testCase.desc, err))
			         ^
libcontainer/cgroups/fs/blkio_test.go:595:13: printf: non-constant format string in call to (*testing.common).Errorf (govet)
			t.Errorf(fmt.Sprintf("test case '%s' failed unexpectedly: %s", testCase.desc, err))
			         ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-14 20:39:15 +08:00
Kir Kolyshkin adedeb993a ci/gha: add Go 1.23, drop 1.21
- drop Go 1.21;
- add Go 1.23;
- for a few jobs that were using Go 1.21, switch to 1.22;

Also, bump go to 1.22 in go.mod.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-14 20:39:15 +08:00
Rodrigo Campos 2ee5564b58 Merge pull request #4378 from lifubang/fix-ci-curlL
[CI] ensure we can download the specific version's go
2024-08-14 14:05:11 +02:00
lifubang be539412b8 ensure we can download the specific version's go
Signed-off-by: lifubang <lifubang@acmcoder.com>
2024-08-14 18:40:49 +08:00
Rodrigo Campos 94eda74ab4 Merge pull request #4374 from kolyshkin/cpu-burst
Fix cpu burst test failure on newer kernels
2024-08-14 12:28:44 +02:00
Akihiro Suda e531ebbca8 Merge pull request #4371 from kolyshkin/simplify
libct/int/seccomp_test: simplify exit code checks
2024-08-14 12:28:08 +09:00
Kir Kolyshkin a7c8d86fc1 tests/int: fix "cpu burst" failure on new kernels
A kernel bug which resulted in cpu.max.burst value read which is 1000
times smaller than it should be has recently been fixed (see [1]).

Adapt the test so it works with either broken or fixed kernel.

[1]: https://lore.kernel.org/all/20240424132438.514720-1-serein.chengyu@huawei.com/

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-13 17:54:23 -07:00
Kir Kolyshkin b437ed3063 tests/int: check_{systemd,cgroup}_value: better log
1. Rename current -> got, expected -> want.
2. check_cgroup_value: add file name to output.
3. Improve functions description.

This is mostly to simplify debugging test failures.
Example output before:

	current 500000 !? 500

After:

	cpu.max.burst: got 500000, want 500

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-13 17:44:31 -07:00
Kir Kolyshkin 2c398bb41d libct/int/seccomp_test: simplify exit code checks
In all the three cases, we check that the program returned non-zero exit
code. This can be done in a much simpler manner.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-10 14:46:43 -07:00
Akihiro Suda 6602681d52 Merge pull request #4369 from TheSiman/patch-1
Fix link to gvariant documentation in systemd docs.
2024-08-09 17:02:44 +10:00
ver4a 171304c8a3 docs/systemd: fix a broken link
Documentation was moved from https://docs.gtk.org/glib/gvariant-text.html to https://docs.gtk.org/glib/gvariant-text-format.html.

Signed-off-by: ver4a <verca@uncontrol.me>
2024-08-07 00:27:57 +02:00
Rodrigo Campos ad5b481dac Merge pull request #4344 from kolyshkin/nilness
ci bumps
2024-08-01 16:00:32 +02:00
Akihiro Suda 3d7bc3bec9 Merge pull request #4359 from cyphar/rootfs-create-mountpoint-refactor
rootfs: consolidate mountpoint creation logic
2024-07-30 02:15:15 +09:00
Akihiro Suda 459ce2f9a8 Merge pull request #4353 from deitch/alpine-build-docs
document how to build under alpine
2024-07-25 23:19:37 +09:00
Aleksa Sarai 1410a6988d rootfs: consolidate mountpoint creation logic
The logic for how we create mountpoints is spread over each mountpoint
preparation function, when in reality the behaviour is pretty uniform
with only a handful of exceptions. So just move it all to one function
that is easier to understand.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-07-25 14:16:05 +10:00
Avi Deitcher 6fc2733a91 document build prerequsites for different platforms
Signed-off-by: Avi Deitcher <avi@deitcher.net>
2024-07-22 20:33:43 +03:00
Kir Kolyshkin 15ec295bb1 ci/gha: bump golangci-lint to v1.59
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-10 16:25:30 -07:00
Kir Kolyshkin bb2db7b4fd libct: drop error from (*Container).currentState return
This function never returns error since 2016 (commit 556f798a),
so let's remove it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-10 16:24:36 -07:00
Kir Kolyshkin c8395b6e53 Enable govet nilness, fix an issue
The code already checked if err == nil above, so the linter complains:

> libcontainer/container_linux.go:534:18: nilness: tautological condition: non-nil != nil (govet)
> 			} else if err != nil {
> 			              ^

Fix the issue, enable the check.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-10 16:04:38 -07:00
Akihiro Suda 3778ae603c Merge pull request #4337 from AkihiroSuda/fix-4328
Revert "libcontainer: seccomp: pass around *os.File for notifyfd"
2024-07-09 15:49:37 +09:00
lfbzhm 8a324d67a8 Merge pull request #4332 from kolyshkin/fix-tags
ci/gha: add go-fix job
2024-07-05 12:40:28 +08:00
Kir Kolyshkin 309a6d91a4 ci/gha: add go-fix job
Add a CI job to ensure go fix produces no result. Quoting
`go doc cmd/fix`:

> Fix finds Go programs that use old APIs and rewrites them to use newer
> ones. After you update to a new Go release, fix helps make the
> necessary changes to your programs.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-03 10:12:25 -07:00
Akihiro Suda a5e660ca5b seccomp-notify.bats: add fcntl to the important syscall list
For issue 4328

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-07-04 02:05:31 +09:00
Akihiro Suda e7848482e2 Revert "libcontainer: seccomp: pass around *os.File for notifyfd"
This reverts commit 20b95f23ca.

> Conflicts:
>	libcontainer/init_linux.go

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-07-03 17:28:12 +09:00
Aleksa Sarai 81d63f265a merge #4331 into opencontainers/runc:main
Sebastiaan van Stijn (1):
  libct/userns: split userns detection from internal userns code

LGTMs: kolyshkin cyphar
2024-07-03 14:24:05 +10:00
Aleksa Sarai 7ea37b94b7 merge #4335 into opencontainers/runc:main
Kir Kolyshkin (1):
  ci/cirrus: switch from CentOS to Almalinux

LGTMs: AkihiroSuda cyphar
2024-07-03 10:48:58 +10:00
Akihiro Suda 683a6345e6 Merge pull request #4326 from kolyshkin/rc2-fixups
CHANGELOG.md: dedup v1.2.0-rc.2 notes
2024-07-03 08:54:55 +09:00
Kir Kolyshkin b18d052bb8 ci/cirrus: switch from CentOS to Almalinux
Remove CentOS 7 as it is EOL.

Add back RHEL 8 clone (CentOS Stream 8 was removed by commit
40bb9c468e).

Switch from CentOS Stream 9 to Almalinux 9.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-02 15:51:31 -07:00
Kir Kolyshkin cc062598cb Merge pull request #4330 from thaJeztah/better_alias
libct/userns: assorted (godoc) improvements
2024-07-01 12:39:28 -07:00
Kir Kolyshkin 8b1c0f7e47 CHANGELOG.md: dedup v1.2.0-rc.2 notes
Remove changes that are already reflected in v1.1.13 changelog:
 - rlimit_nofile fix;
 - rt_period vs rt_runtime fix;
 - gpg vs keyboxd fix;
 - nsexec debug log fix;
 - fips faking;
 - vagrant Fedora 39 bump;
 - golangci-lint bump;
 - x/net bump;
 - centos stream 8 removal;
 - codespell ci fixes.

Compact some of the entries that are related (e.g. about actuated-ci).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-01 10:24:22 -07:00
Sebastiaan van Stijn 6980adb67c libct/userns: implement RunningInUserNS with sync.OnceValue
Now that we dropped support for go < 1.21, we can use this; moving
the sync.once out of the runningInUserNS() implementation would also
allow for it to be more easily tested if we'd decide to.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:20:58 +02:00
Sebastiaan van Stijn b3b31ff27c libct/userns: make fuzzer Linux-only, and remove stub for uidMapInUserNS
The fuzzer for this only runs on Linux; rename the file to be Linux-only
so that we don't have to stub out the uidMapInUserNS function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:20:58 +02:00
Sebastiaan van Stijn 5b09a71228 libct/userns: change RunningInUserNS to a wrapper instead of an alias
This was a poor decision on my side; 4316df8b53
moved this utility to a separate package, and split the exported function
from the implementation (and stubs). Out of convenience, I used an alias
for the latter part, but there's two downsides to that;

- `RunningInUserNS` being an exported var means that (technically) it can
  be replaced by other code; perhaps that's a "feature", but not one we
  intended it to be used for.
- `RunningInUserNS` being implemented through a var / alias means it's
  also documented as such on [pkg.go.dev], which is confusing.

This patch changes it to a regular function, acting as a wrapper for
the underlying implementations. While at it, also slightly touching
up the GoDoc to describe its functionality / behavior.

[pkg.go.dev]: https://pkg.go.dev/github.com/opencontainers/runc@v1.1.13/libcontainer/userns#RunningInUserNS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:20:35 +02:00
Kir Kolyshkin 7bcb61118b Merge pull request #4329 from thaJeztah/rm_old_buildtags
remove pre-go1.17 build-tags
2024-07-01 10:18:11 -07:00
Sebastiaan van Stijn 30b530ca94 libct/userns: split userns detection from internal userns code
Commit 4316df8b53 isolated RunningInUserNS
to a separate package to make it easier to consume without bringing in
additional dependencies, and with the potential to move it separate in
a similar fashion as libcontainer/user was moved to a separate module
in commit ca32014adb. While RunningInUserNS
is fairly trivial to implement, it (or variants of this utility) is used
in many codebases, and moving to a separate module could consolidate
those implementations, as well as making it easier to consume without
large dependency trees (when being a package as part of a larger code
base).

Commit 1912d5988b and follow-ups introduced
cgo code into the userns package, and code introduced in those commits
are not intended for external use, therefore complicating the potential
of moving the userns package separate.

This commit moves the new code to a separate package; some of this code
was included in v1.1.11 and up, but I could not find external consumers
of `GetUserNamespaceMappings` and `IsSameMapping`. The `Mapping` and
`Handles` types (added in ba0b5e2698) only
exist in main and in non-stable releases (v1.2.0-rc.x), so don't need
an alias / deprecation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 20:06:30 +02:00
Sebastiaan van Stijn c14213399a remove pre-go1.17 build-tags
Removed pre-go1.17 build-tags with go fix;

    go fix -mod=readonly ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-29 15:45:25 +02:00