Commit Graph

5846 Commits

Author SHA1 Message Date
Kir Kolyshkin 1a3ee4966c list: use Info(), fix race with delete
Since commit 551629417 we can (and should) use Info() to get access to
file stat. Do this.

While going over directory entries, a parallel runc delete can remove
an entry, and with the current code it results in a fatal error (which
was not observed in practice, but looks quite possible). To fix,
add a special case to continue on ErrNotExist.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-25 15:34:04 -08:00
Kir Kolyshkin 095929b15e list: getContainers: less indentation
Instead of a huge if {} block, use continue.

Best reviewed with --ignore-all-space.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-25 15:31:54 -08:00
Mrunal Patel a1727ef58c Merge pull request #3345 from kolyshkin/rodev
Fix working with read-only /dev
2022-01-25 13:27:36 -08:00
Sebastiaan van Stijn a934123d21 Merge pull request #3319 from kolyshkin/chown-not-needed
libct: Create: rm unneeded chown
2022-01-24 14:55:09 +01:00
Akihiro Suda c9ad96f63e Merge pull request #3335 from kolyshkin/mount-prop-empty-key
libct/specconv: rm empty key from mountPropagationMapping
2022-01-24 16:29:58 +09:00
Akihiro Suda a2805a31e1 Merge pull request #3339 from kolyshkin/rtd-faster-followup
libct/intelrdt: explain why mountinfo is required
2022-01-24 16:29:37 +09:00
Akihiro Suda 4ebd33aa6a Merge pull request #3346 from opencontainers/dependabot/go_modules/github.com/cilium/ebpf-0.8.0
build(deps): bump github.com/cilium/ebpf from 0.7.0 to 0.8.0
2022-01-24 16:28:33 +09:00
dependabot[bot] cb36410868 build(deps): bump github.com/cilium/ebpf from 0.7.0 to 0.8.0
Bumps [github.com/cilium/ebpf](https://github.com/cilium/ebpf) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/cilium/ebpf/releases)
- [Commits](https://github.com/cilium/ebpf/compare/v0.7.0...v0.8.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>
2022-01-24 04:15:07 +00:00
Kir Kolyshkin 146c8c0c62 libct: fixStdioPermissions: ignore EROFS
In case of a read-only /dev, it's better to move on and let whatever is
run in a container to handle any possible errors.

This solves runc exec for a user with read-only /dev.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-21 17:53:03 -08:00
Kir Kolyshkin 18c4760aed libct: fixStdioPermissions: skip chown if not needed
Since we already called fstat, we know the current file uid. In case it
is the same as the one we want it to be, there's no point in trying
chown.

Remove the specific /dev/null check, as the above also covers it
(comparing /dev/null uid with itself is true).

This also fixes runc exec with read-only /dev for root user.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-21 17:46:10 -08:00
Kir Kolyshkin b7fdb68848 libct: fixStdioPermissions: minor refactoring
Use os/file Chown method instead of bare unix.Fchown as it already have
access to underlying fd, and produces nice-looking errors. This allows
us to remove our error wrapping and some linter annotations.

We still use unix.Fstat since os.Stat access to os-specific fields
like uid/gid is not very straightforward. The only change here is to use
file name (rather than fd) in the error text.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-21 17:39:50 -08:00
Aleksa Sarai 2a62093dbb merge branch 'pr-3344'
Kir Kolyshkin (2):
  CHANGELOG: add #3306
  CHANGELOG.md: nit

LGTMs: AkihiroSuda cyphar
Closes #3344
2022-01-21 16:54:29 +11:00
Kir Kolyshkin 2eb6ac5347 CHANGELOG: add #3306
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-20 18:47:52 -08:00
Kir Kolyshkin e4d23d50fa CHANGELOG.md: nit
The 1.1.0 "Changed" heading level is not proper.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-20 18:42:21 -08:00
Kir Kolyshkin 5e201e7ce2 libct/intelrdt: explain why mountinfo is required
For the Nth time I wanted to replace parsing mountinfo with
statfs and the check for superblock magic, but it is not possible
since some code relies of mount options check which can only
be obtained via mountinfo.

Add a note about it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-20 10:36:45 -08:00
Sebastiaan van Stijn 62133e3840 Merge pull request #3306 from kolyshkin/rdt-faster
Faster Intel RDT init if the feature is unavailable
2022-01-19 11:24:41 +01:00
Aleksa Sarai 17543edd15 merge branch 'pr-3338'
Aleksa Sarai (2):
  VERSION: back to development
  VERSION: release runc v1.1.0

LGTMs: AkihiroSuda thaJeztah hqhq
Closes #3338
2022-01-18 09:44:11 +11:00
Aleksa Sarai d7f7b22a85 VERSION: back to development
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2022-01-17 19:16:33 +11:00
Aleksa Sarai 067aaf8548 VERSION: release runc v1.1.0
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.1.0
2022-01-17 19:16:31 +11:00
Kir Kolyshkin c45eed9a4a libct/specconv: rm empty key from mountPropagationMapping
It is a tad cleaner this way.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-07 11:22:22 -08:00
Akihiro Suda c83abc503d Merge pull request #3331 from kolyshkin/nsenter-unsup
Refuse to build runc without nsenter
2022-01-05 14:18:02 +09:00
Kir Kolyshkin c0e300f109 Refuse to build runc without nsenter
Commit 4d1d6185ab added this
nsenter_unsupported.go file in order for nsenter to be a valid (but
empty, non-functional) Go package on unsupported platforms.

As a result, runc can be build successfully without CGO, which results
in a non-working and hard-to-debug binary (see issue 3330).

As the functionality of being able to compile a package which is
definitely not working is questionable, and I can't think of any use
cases, let's remove the file.

With this, runc can no longer be build without CGO:

	[kir@kir-rhat runc]$ CGO_ENABLED=0 make runc
	go build -trimpath "-buildmode=pie"  -tags "seccomp" -ldflags "-X main.gitCommit=v1.0.0-452-g00f56786-dirty -X main.version=1.1.0-rc.1+dev " -o runc .
	go build github.com/opencontainers/runc/libcontainer/nsenter: build constraints exclude all Go files in /home/kir/go/src/github.com/opencontainers/runc/libcontainer/nsenter

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-04 15:49:41 -08:00
Akihiro Suda 00f56786bb Merge pull request #3328 from opencontainers/dependabot/go_modules/github.com/checkpoint-restore/go-criu/v5-5.3.0
build(deps): bump github.com/checkpoint-restore/go-criu/v5 from 5.2.0 to 5.3.0
2021-12-23 11:00:22 +09:00
dependabot[bot] e155b3322c build(deps): bump github.com/checkpoint-restore/go-criu/v5
Bumps [github.com/checkpoint-restore/go-criu/v5](https://github.com/checkpoint-restore/go-criu) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/checkpoint-restore/go-criu/releases)
- [Commits](https://github.com/checkpoint-restore/go-criu/compare/v5.2.0...v5.3.0)

---
updated-dependencies:
- dependency-name: github.com/checkpoint-restore/go-criu/v5
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-22 04:18:26 +00:00
Akihiro Suda 81044ad7c9 Merge pull request #3325 from kolyshkin/rm-go115
libct/cg: rm go 1.15 compatibility
2021-12-15 11:39:50 +09:00
Kir Kolyshkin 5c7e898186 libct/cg: rm go 1.15 compatibility
Since commit 12e99a0f8d we do require Go >= 1.16, so this file
is no longer needed.

Also, this actually ensures that go >= 1.16 is used (otherwise
libcontainer/cgroups/getallpids.go won't compile).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-14 13:08:47 -08:00
Aleksa Sarai 7113a40898 merge branch 'pr-3323'
Aleksa Sarai (2):
  VERSION: back to development
  VERSION: release v1.1.0-rc.1

LGTMs: AkihiroSuda kolyshkin
Closes #3323
2021-12-14 15:27:16 +11:00
Aleksa Sarai 4773769ce1 VERSION: back to development
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-12-14 14:23:02 +11:00
Aleksa Sarai 55df1fc4c8 VERSION: release v1.1.0-rc.1
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
v1.1.0-rc.1
2021-12-14 14:23:00 +11:00
Kir Kolyshkin 6c1e2ecc20 Merge pull request #3320 from cyphar/changelog
CHANGELOG: add an in-repo changelog file
2021-12-13 12:51:14 -08:00
Aleksa Sarai a8f9d5defc CHANGELOG: add an in-repo changelog file
This will make releases much simpler. I've back-filled the changelog
with everything since runc 1.0.0 (there's not much point going further
back than that).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-12-13 13:22:11 +11:00
Kir Kolyshkin 024adbb1b9 libct: Create: rm unneeded chown
Commit 7cfb107f2c started using unix.Geteuid(), unix.Getegid() as
uid/gid argument for chown. It seems that it should have removed chown
entirely, since, according to mkdir(2),

> The newly created directory will be owned by the effective user ID of
> the process. If the directory containing the file has the
> set-group-ID bit set, or if the filesystem is mounted with BSD
> group semantics (mount -o bsdgroups or, synonymously mount -o grpid),
> the new directory will inherit the group ownership from its parent;
> otherwise it will be > owned by the effective group ID of the process.

So, the only effect of the chown after mkdir is ignoring the sgid bit
on the parent directory (which is probably not the right thing to do).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-10 18:49:25 -08:00
Aleksa Sarai 7e792c9236 merge branch 'pr-3301'
Kir Kolyshkin (1):
  libct/utils: ResolveRootfs: remove

LGTMs: AkihiroSuda cyphar
Closes #3301
2021-12-09 23:11:12 +11:00
Akihiro Suda 4e56a2b35e Merge pull request #3313 from kolyshkin/int-nits
libct/int: minor improvements
2021-12-09 19:20:59 +09:00
Aleksa Sarai e7dfcc93af Merge pull request #3314 from kolyshkin/seccomp-2.5.3
release: update libseccomp to 2.5.3, minor script fixes
2021-12-09 20:36:54 +11:00
Kir Kolyshkin 6d2067a4bf script/seccomp.sh: fix argc check
This check was always broken, and it slipped through the cracks because
we never run it without additional architectures now.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-09 00:59:47 -08:00
Kir Kolyshkin 457ca62f1f script/release_*.sh: fix usage
- release_build: fix -H <hash_cmd> option (was -h)
- release_sign: add -H and -S options

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-09 00:59:43 -08:00
Kir Kolyshkin c729594cdd deps: update libseccomp to 2.5.3
It was released about a month ago. I don't see anything major
in the changelog but it makes sense to keep tracking upstream deps.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-09 00:38:25 -08:00
Aleksa Sarai 1b747a43f0 merge branch 'pr-3309'
Aleksa Sarai (1):
  release: correctly handle binary signing for "make releaseall"

LGTMs: AkihiroSuda kolyshkin
Closes #3309
2021-12-09 16:47:31 +11:00
Kir Kolyshkin 5d77962099 tests/int: use update_config in hooks test
Using "$@" instead of $1 in update_config() allows us to use it from
hooks.bats, where jq is used with more options than usual.

We need to disable SC2016 as otherwise shellcheck sees $something inside
single quotes and think we are losing the shell expansion (we are not).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-08 21:36:27 -08:00
Kir Kolyshkin 9e798e26cb tests/int: ability to specify binary
This can be used to specify a different runc binary, for example:

	sudo -E RUNC=$PWD/runc.mine tests/integration/cwd.bats

A different (but compatible enough) runtime also works:

	sudo -E RUNC=/usr/local/bin/crun tests/integration/cwd.bats

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-12-08 21:25:05 -08:00
Kir Kolyshkin 13b0806f12 Merge pull request #3272 from AkihiroSuda/mount-rro
Support recursive mount attrs ("rro", "rnosuid", "rnodev", ...)
2021-12-08 11:02:26 -08:00
Aleksa Sarai 4b22d8e446 Merge branch 'pr-3310'
Akihiro Suda (2):
  types/features: clarify MountOptions
  Mark `runc features` experimental

LGTMs: cyphar mrunalp
Closes #3310
2021-12-08 17:07:21 +11:00
Mrunal Patel cd07af28ce Merge pull request #3304 from kolyshkin/lint-extra
ci: enable extra linters for new code
2021-12-07 15:58:10 -08:00
Akihiro Suda 97688ddff3 types/features: clarify MountOptions
`MountOptions` does not contain `const void *data` options.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-07 18:36:04 +09:00
Akihiro Suda deb0a5f2ef Mark runc features experimental
Follow-up to PR 3296

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-07 17:51:39 +09:00
Akihiro Suda 382eba4354 Support recursive mount attrs ("rro", "rnosuid", "rnodev", ...)
The new mount option "rro" makes the mount point recursively read-only,
by calling `mount_setattr(2)` with `MOUNT_ATTR_RDONLY` and `AT_RECURSIVE`.
https://man7.org/linux/man-pages/man2/mount_setattr.2.html

Requires kernel >= 5.12.

The "rro" option string conforms to the proposal in util-linux/util-linux Issue 1501.

Fix issue 2823

Similary, this commit also adds the following mount options:
- rrw
- r[no]{suid,dev,exec,relatime,atime,strictatime,diratime,symfollow}

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-07 17:39:57 +09:00
Akihiro Suda ba935a51a6 Support nosymfollow mount option (kernel 5.10)
See MS_NOSYMFOLLOW in mount(2)

https://man7.org/linux/man-pages/man2/mount.2.html

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-07 17:33:49 +09:00
Akihiro Suda f8c48e4617 go.mod: golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-07 17:33:46 +09:00
Aleksa Sarai acd8f12f24 release: correctly handle binary signing for "make releaseall"
My GPG keys are not available inside the container, so it makes little
sense to try to sign the binaries inside the container's release.sh. The
solution is to split things into separate build and sign stages, with
signing ocurring after the in-Docker build.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-12-07 18:10:34 +11:00