Commit Graph

7125 Commits

Author SHA1 Message Date
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
Kir Kolyshkin ab010ae1ef Merge pull request #4319 from lifubang/fix-execfifo-delete-error
Try to delete exec fifo file when failure in creation
2024-06-26 11:53:34 -07:00
Kir Kolyshkin 213fefd25d Merge pull request #4317 from lifubang/release-1.2.0-rc.2
Release 1.2.0-rc.2
2024-06-26 10:23:31 -07:00
lifubang 5ea7625401 VERSION: back to development
Signed-off-by: lifubang <lifubang@acmcoder.com>
2024-06-26 20:03:03 +08:00
lifubang f2d2ee5e45 VERSION: release 1.2.0-rc.2
Signed-off-by: lifubang <lifubang@acmcoder.com>
v1.2.0-rc.2
2024-06-26 20:03:03 +08:00
Kir Kolyshkin 095e9e5c02 Merge pull request #4324 from kolyshkin/michael
MAINTAINERS: move crosbymichael to EMERITUS; remove chief maintainer role
2024-06-24 18:21:38 -07:00
Kir Kolyshkin ee601b87f9 MAINTAINERS_GUIDE: rm chief maintainer role
Since Michael Crosby is stepping down, and we don't want to nominate
someone else to be a chief maintainer, let's remove the position.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-24 16:50:52 -07:00
Kir Kolyshkin d6563f6bcd MAINTAINERS: move crosbymichael to EMERITUS
I talked to Michael, he says he is stepping down as a maintainer, being
busy with other stuff.

Thank you for all the hard work that you did!

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-23 12:53:57 -07:00
Kir Kolyshkin 90ebcca8f1 Merge pull request #4314 from kolyshkin/maint-rata
MAINTAINERS: add Rodrigo Campos

LGTMs: crosbymichael mrunalp dqminh hqhq cyphar AkihiroSuda kolyshkin thaJeztah lifubang
Vote: +8 -0 #1
2024-06-20 17:00:07 -07:00
Akihiro Suda 8256a9384f Merge pull request #4322 from lifubang/changelog-sortby-ver
Put the changelog of v1.1.13 after v1.2.0-rc.1
2024-06-20 14:55:10 +09:00
lfbzhm ad976aa155 put the changelog of v1.1.13 after v1.2.0-rc.1
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
2024-06-19 14:09:02 +00:00
Sebastiaan van Stijn fd5675e386 Merge pull request #4321 from lifubang/update-changelog-release-1.1.13
update changelog after v1.1.13 released
2024-06-14 01:35:57 +02:00
Akihiro Suda ac26d3d158 Merge pull request #4320 from kolyshkin/nits
Some nits I found from older PRs
2024-06-14 07:45:34 +09:00
lfbzhm 4e2d7c0a6e update changelog after v1.1.13 released
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
2024-06-13 22:45:00 +00:00
Kir Kolyshkin 2cb46c6e0d script/keyring_validate.sh: fix a typo
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-13 08:03:08 -07:00
Kir Kolyshkin d6e427e1ea runc exec: avoid stuttering in error messages
An error from strconv.Atoi already contains the text it fails to parse.
Because of that, errors look way too verbose, e.g.:

	[root@kir-rhat runc-tst]# ./runc exec --user 1:1:1 2345 true
	ERRO[0000] exec failed: parsing 1:1 as int for gid failed: strconv.Atoi: parsing "1:1": invalid syntax

With this patch, the error looks like this now:

	[root@kir-rhat runc]# ./runc exec --user 1:1:1 2345 true
	ERRO[0000] exec failed: bad gid: strconv.Atoi: parsing "1:1": invalid syntax

Still not awesome, but better.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-12 21:03:10 -07:00
Kir Kolyshkin a6d46ed1a7 runc exec: improve options parsing
1. Do not ask for the same option value twice.

2. For tty, we always want false, unless specified, and this is what
   GetBool gets us.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-12 20:59:01 -07:00
lfbzhm 9d600197be Merge pull request #4271 from kolyshkin/two-inits
libct.Start: fix locking, do not allow a second container init
2024-06-11 18:37:40 +08:00
Kir Kolyshkin 42cea2ecb4 libct: don't allow to start second init process
By definition, every container has only 1 init (i.e. PID 1) process.

Apparently, libcontainer API supported running more than 1 init, and
at least one tests mistakenly used it.

Let's not allow that, erroring out if we already have init. Doing
otherwise _probably_ results in some confusion inside the library.

Fix two cases in libct/int which ran two inits inside a container.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-10 22:30:03 -07:00
Kir Kolyshkin e3e1072575 libct: fix locking in Start/Run/Exec
1. The code to call c.exec from c.Run was initially added by commit
   3aacff695. At the time, there was a lock in c.Run. That lock was
   removed by commit bd3c4f84, which resulted in part of c.Run executing
   without the lock.

2. All the Start/Run/Exec calls were a mere wrappers for start/run/exec
   adding a lock, but some more code crept into Start at some point,
   e.g. by commits 805b8c73 and 108ee85b8. Since the reason mentioned in
   commit 805b8c73 is no longer true after refactoring, we can fix this.

Fix both issues by moving code out of wrappers, and adding locking into
c.Run.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-10 22:30:03 -07:00
Kir Kolyshkin 304a4c0fee libct: createExecFifo: rm unneeded os.Stat
In case file already exists, mknod(2) will return EEXIST.

This os.Stat call was (inadvertently?) added by commit 805b8c73.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-10 22:30:03 -07:00
lifubang e7294527e2 try to delete exec fifo file when failure in creation
Signed-off-by: lifubang <lifubang@acmcoder.com>
2024-06-10 19:51:48 +08:00
lfbzhm 349e5ab7c1 Merge pull request #4283 from kolyshkin/revert-cpu-aff
Revert "Set temporary single CPU affinity before cgroup cpuset transition"
2024-06-10 06:54:53 +08:00
Kir Kolyshkin 1c505fffdc Revert "Set temporary single CPU affinity..."
There's too much logic here figuring out which CPUs to use. Runc is a
low level tool and is not supposed to be that "smart". What's worse,
this logic is executed on every exec, making it slower. Some of the
logic in (*setnsProcess).start is executed even if no annotation is set,
thus making ALL execs slow.

Also, this should be a property of a process, rather than annotation.

The plan is to rework this.

This reverts commit afc23e3397.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-10 06:31:03 +08:00
Kir Kolyshkin 67a1477959 Merge pull request #4285 from kolyshkin/f40
Vagrantfile.fedora: bump to F40
2024-06-09 15:26:38 -07:00
Akihiro Suda 30a7d9b863 Merge pull request #4186 from kolyshkin/multi-line
libct/cg: write unified resources line by line
2024-06-10 06:27:07 +09:00
Kir Kolyshkin f8f1bc9a30 Vagrantfile.fedora: bump to F40
Get the image from Fedora directly.

Also, remove the comment about cgroup v2 as it is also tested on Ubuntu
22.04 now.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-06-09 14:15:18 -07:00