Commit Graph

4843 Commits

Author SHA1 Message Date
Kenta Tada 25987d03e3 libcontainer/intelrdt: adjust the file mode
This commit adjusts the file mode to use the latest golang style
and also changes the file mode value in accordance with default.

Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2021-01-08 15:22:24 +09:00
Kir Kolyshkin 04b7b7d3c3 Merge pull request #2721 from kolyshkin/gha-vm
ci: replace travis with GHA for Fedora 33 and CentOS 7
2021-01-06 14:42:25 -08:00
Kir Kolyshkin 2dc1bf91a4 ci: move Fedora 33 and CentOS 7 tests to gha
...and remove .travis.yml as GHA now covers everything it used to
(unless I overlooked something).

Inspired by https://github.com/containerd/containerd/pull/4279

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 21:03:12 -08:00
Kir Kolyshkin e431fe60f8 ci: move misc validate tasks from travis to gha
Note that `make ci` in Travis included `make test`, but we're already
doing that elsewhere (see .github/workflows/test.yml).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 21:01:32 -08:00
Kir Kolyshkin 7ecba232e9 ci: move cross compile check from travis to gha
In here we have to use Docker, as Ubuntu does not support
all the architectures we're compile-testing here.

Since this is the only step that is using Docker,
there is no sense to separate `make runcimage` from
the rest of it. In case we'll have to use Docker image
more, it will make sense to do so.

While at it, ditch script/tmpmount (added by commit 1735ad788f),
because
 - it required root (because mount);
 - it is probably no longer needed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:45:28 -08:00
Kir Kolyshkin 8ccd39a91b ci: move commit length check from travis to gha
Using https://github.com/tim-actions/commit-message-checker-with-regex

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:44:55 -08:00
Kir Kolyshkin 1125ae7835 tests/events.bats: unify duplicated code
There are three tests that only differ in delays (and a few other
minor details line whitespace formatting and number of retries).

Let's unify those so maintaining this code will be easier.

This also implicitly increases the number of retries from 3 to 10
for the non-default --interval tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:26:03 -08:00
Mrunal Patel 09523b79d0 Merge pull request #2706 from kolyshkin/netns
libct/configs/validate.sysctl: fix host netns check
2021-01-04 09:57:16 -08:00
Mrunal Patel d745daeac4 Merge pull request #2711 from kolyshkin/2701-followup
libct/int/execin_tty: do help debug a flake
2021-01-04 09:39:51 -08:00
Mrunal Patel ce47909bc8 Merge pull request #2712 from kolyshkin/fix-chdir-II
libct/init_linux: reorder chdir to fix EPERM
2021-01-04 09:32:27 -08:00
Akihiro Suda 5efdc0c5a4 Merge pull request #2678 from xiaochenshen/rdt-rm-init
libcontainer/intelrdt: rm init() from intelrdt.go
2020-12-23 01:41:14 +09:00
Kir Kolyshkin 27268b1a7e tests/int/cwd: add test case for cwd not owned by runc
The test setup is complicated, as we want to run it as non-root,
but we need to create a directory owned by a particular user,
and root is needed for chown. To do that, we hijack enable_idmap.

Now, there is no ideal place to clean up AUX_DIR. A function
cleanup is called after the test to do so. Note that it won't
be called if the test fails.

This was verified to fail before and pass after the
previous commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 13:23:27 -08:00
Peter Hunt d869d05aba libctr/init_linux: reorder chdir
commit 5e0e67d76c moved the chdir to be one of the
first steps of finalizing the namespace of the container.

However, this causes issues when the cwd is not accessible by the user running runc, but rather
as the container user.

Thus, setupUser has to happen before we call chdir. setupUser still happens before setting the caps,
so the user should be privileged enough to mitigate the issues fixed in 5e0e67d76c

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2020-12-18 12:59:02 -08:00
Kir Kolyshkin 8bd3b8786b test: add case for GH #2086
Commit 5e0e67d7 ("fix permission denied") modified some code but
did not provide a test case.

This is a test case that was tested to fail before and succeed after
the above commit.

For more details, see https://github.com/opencontainers/runc/pull/2086

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 12:56:48 -08:00
Kir Kolyshkin cb3dd9d8c7 libct/configs/validate: test for bind-mounted netns
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:32:46 -08:00
Kir Kolyshkin 8e8661e124 libct/configs/validate/sysctl: fix repeated netns checks
In case many net.* sysctls are provided, and we're not running
in the host netns, the function keep repeating isNetNS check
for every such sysctl. This is a waste of resources.

Do the isNetNS check only once, and only if needed.

Note that using sync.Once() is not really needed here; we could
have used a boolean variable to skip the repeated check, but
it looks more idiomatic that way.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:32:39 -08:00
Kir Kolyshkin 2dce06995a libct/configs/validate: fix host netns check
In case nsfs mount (such as /run/docker/netns/xxxx) is provided as
the netns path, the current way of determining whether path is of
host netns or not is not working.

The proper way to check is to do stat(2) and compare dev_t and
inode fields, which is what this commit does.

This is a minimal fix which does not try to optimize repeated
check in case more than one net.* sysctl is given and there is
no error.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:29:13 -08:00
Kir Kolyshkin 77b5d8ab5a Merge pull request #2710 from Creatone/creatone/fscommon-close-fd
libctl/cgroups/fscommon: close fd
2020-12-18 09:09:30 -08:00
Kir Kolyshkin 2143b36835 libct/int/execin_tty: do help debug a flake
Do help to debug https://github.com/opencontainers/runc/issues/2425.

Previous commit 1909051b9c modified the code in the wrong place.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:00:33 -08:00
Paweł Szulik e709b8abe0 libctl/cgroups/fscommon: close fd
Signed-off-by: Paweł Szulik <pawel.szulik@intel.com>
2020-12-18 14:32:23 +01:00
Mrunal Patel 2e1c1de9de Merge pull request #2708 from loyou/master
checkProcMount: add /proc/slabinfo to whitelist
2020-12-17 17:31:17 -08:00
Mrunal Patel 2a9d7817d7 Merge pull request #2709 from AkihiroSuda/remove-apparmor-selinux-tags
remove "apparmor" and "selinux" build tags
2020-12-17 17:30:30 -08:00
Xiaochen Shen 325a74ddec libcontainer/intelrdt: rm init() from intelrdt.go
Use sync.Once to init Intel RDT when needed for a small speedup to
operations which do not require Intel RDT.

Simplify IntelRdtManager initialization in LinuxFactory.

Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
2020-12-16 23:37:31 +08:00
Akihiro Suda cb26930680 remove "selinux" build tag (Always compile SELinux support)
The build tag was removed in go-selinux v1.8.0: https://github.com/opencontainers/selinux/pull/132

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-16 17:41:11 +09:00
Akihiro Suda 552a1c7bb1 remove "apparmor" build tag (Always compile AppArmor support)
The apparmor tag was introduced in a01ed80 (2014) to make cgo dependency
on libapparmor optional.

However, the cgo dependency was removed in db093f6 (2017), so it is no
longer meaningful to keep apparmor build tag.

Close #2704

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-16 17:39:48 +09:00
Feng Sun 48b8eb0952 checkProcMount: add /proc/slabinfo to whitelist
With lxcfs commit, slabinfo should can be mounted:
"proc_fuse: add /proc/slabinfo with slab accounting memcg"
https://github.com/lxc/lxcfs/commit/1cc68c8bfa

Signed-off-by: Feng Sun <loyou85@gmail.com>
2020-12-16 09:40:04 +08:00
Akihiro Suda 544048b865 Merge pull request #2689 from kolyshkin/get-cgroup-mounts-all
libct/cgroup/utils: fix GetCgroupMounts(all=true)
2020-12-08 11:48:13 +09:00
Akihiro Suda 4d8d989404 Merge pull request #2668 from kolyshkin/openat2
libcontainer/cgroups/fscommon: add openat2 support
2020-12-07 14:51:17 +09:00
Akihiro Suda b923ff4373 Merge pull request #2701 from kolyshkin/exec-tty
libct/int/execin_tty: help debug a flake
2020-12-05 09:09:34 +09:00
Akihiro Suda 4b055ff583 Merge pull request #2695 from kolyshkin/linter-nits
Misc linter nits
2020-12-04 12:35:06 +09:00
Kir Kolyshkin 1909051b9c libct/int/execin_tty: help debug a flake
This helps to debug https://github.com/opencontainers/runc/issues/2425

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 17:29:54 -08:00
Mrunal Patel 166068a0ff Merge pull request #2691 from kolyshkin/dont-compile-criu
Dockerfile: use binary criu release; update some ci deps
2020-12-03 16:27:52 -08:00
Kir Kolyshkin 8518317c39 Merge pull request #2407 from piowag/2365-blkio-getstat-update
Update blkio GetStats
2020-12-03 15:46:20 -08:00
Kir Kolyshkin 9792929515 libct/intelrdt: fix a staticcheck warning
> libcontainer/intelrdt/monitoring.go:24:2: SA5001: should check returned error before deferring file.Close() (staticcheck)
> 	defer file.Close()
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 6437086ef5 libct/addCriu*Mount: fix gosimple warning
> libcontainer/container_linux.go:768:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^
> libcontainer/container_linux.go:1150:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin d0b5954826 libct/checkCriuFeatures: fix gosimple linter warning
> libcontainer/container_linux.go:683:2: S1021: should merge variable declaration with assignment on next line (gosimple)
> 	var t criurpc.CriuReqType
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3de5c51454 libct/int: don't hardcode CAP_NET_ADMIN
... use the one from unix instead.

Coincidentally, this fixes this warning from gosimple linter:

> libcontainer/integration/exec_test.go:448:2: S1021: should merge variable declaration with assignment on next line (gosimple)
>	var netAdminBit uint
>	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3387422bf9 libct/int: fix "simple" linter warnings
This fixes the following warnings:

> libcontainer/integration/exec_test.go:369:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputStatus := string(stdout.Bytes())
>	                ^
> libcontainer/integration/exec_test.go:422:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputStatus := string(stdout.Bytes())
>	                ^
> libcontainer/integration/exec_test.go:486:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputGroups := string(stdout.Bytes())
>	                ^
> libcontainer/integration/execin_test.go:191:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputGroups := string(stdout.Bytes())
>	                ^
> libcontainer/integration/execin_test.go:474:9: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	out := string(stdout.Bytes())
>	       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 11680cd2c7 libct: fix "unused" linter warning
Commit 4415446c32 introduces this function which is never used.
Remove it.

This fixes

> libcontainer/container_linux.go:1813:26: func `(*linuxContainer).deleteState` is unused (unused)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin a99ecc9ea2 libct/cg/utils: silence a linter warning
> libcontainer/cgroups/utils.go:282:4: SA4006: this value of `paths` is never used (staticcheck)
>			paths = make(map[string]string)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3c9b03fd73 libct/cg/fscommon: log openat2 init failures
In case we get ENOSYS from openat2(2), this is expected, so log that
we're falling back to using securejoin as debug.

Otherwise, log it as a warning (as the error is unexpected, but we're
still good to go).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:19:06 -08:00
Kir Kolyshkin 6bda460000 libcontainer/cgroups/fscommon: add openat2 support
In case openat2 is available, it will be used to guarantee
that we're not accessing anything other than cgroupfs[2] files.

In cases when openat2 is not available, or when cgroup has a
non-standard prefix (not "/sys/fs/cgroup", which might theoretically
be the case on some very old installs and/or very custom systems),
fall back to using securejoin + os.Open like we did before.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:19:06 -08:00
Piotr Wagner 31b0151fc9 move blkio stat gathering to loop
Signed-off-by: Piotr Wagner <piotr.wagner@intel.com>
2020-12-03 08:18:43 -08:00
Piotr Wagner 990a6c57f1 cgroups: update blkio GetStats
Signed-off-by: Piotr Wagner <piotr.wagner@intel.com>
2020-12-03 08:18:43 -08:00
Kir Kolyshkin be56333fff bats: update to 1.2.1
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:28:40 -08:00
Kir Kolyshkin f15c4cca2c Update umoci to 0.4.6
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:28:34 -08:00
Kir Kolyshkin 4344bd8f14 Dockerfile: use binary criu release
This "reverts" commit 9ff7b82f9. We use the repo provided and maintained
by the CRIU team instead of compiling it from source.

While at it,

1. Don't install packages that were solely needed to compile CRIU.

2. Combine all apt-related stuff into a single step, so we don't
   download and then remove apt metadata 3 times.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:27:42 -08:00
Akihiro Suda bd013b6e4d Merge pull request #2698 from cyphar/memfd_create-hardcode-sysnum
nsenter: hard-code memfd_create(2) syscall numbers
2020-12-03 12:01:21 +09:00
Mrunal Patel 56a1f1f70f Merge pull request #2697 from kolyshkin/validate-nits
.github/workflows/validate: nits
2020-12-02 10:20:38 -08:00
Akihiro Suda 351787708a Merge pull request #2679 from thaJeztah/isolate_device
libcontainer: isolate libcontainer/devices
2020-12-02 18:00:38 +09:00