Commit Graph

1835 Commits

Author SHA1 Message Date
Mauricio Vásquez 5c0342ba2c libcontainer: fix bad conversion from syscall.Errno to error
The correct way to do that conversion according to
https://pkg.go.dev/syscall#Errno is:

```
err = nil
if errno != 0 {
	err = errno
}
```

In this case the error check will always report a false positive in
unix.RawSyscall(unix.SYS_SECCOMP, ...), probably nobody has faced this
problem because the code takes the other path in most of the cases.

Fixes: 7a8d7162f9 ("seccomp: prepend -ENOSYS stub to all filters")

Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
2021-02-03 16:12:33 -05:00
Aleksa Sarai 7e3c3e8c22 merge branch 'pr-2780'
Sebastiaan van Stijn (1):
  Remove "PatchAndLoad" stub as it's not used without seccomp enabled

LGTMs: @kolyshkin @cyphar
Closes #2780
2021-02-03 00:45:32 +11:00
Kir Kolyshkin 76ae1f5c31 libct/cg/fs/freezer: fix freezing race
Before this commit, Set() used GetState() to check the freezer state
and retry the operation if the actual state still differs from requested.
This should help with the situation when a new process (such as one
added by runc exec) is added to the container's cgroup while it's being
freezed by the kernel, but it's not working as it should.

The problem is, GetState() never returns FREEZING state, looping until
the state is either FROZEN or THAWED, so Set() does not have a chance
to repeate the freeze attempt.

As a result, the container might end up stuck in a FREEZING state,
with GetState() never returning (which in turn blocks some other
operations).

One way to fix this would be to have GetState returning FREEZING state
instead of retrying ad infinitum. It would result in changing the public
API, and no callers of GetState expects it to return this.

To fix, let's not use GetState() from Set(). Instead, read the
freezer.state file directly and act accordingly -- return success
on FROZEN, retry on FREEZING, and error out on any other (unexpected)
value.

While at it, further improve the code:
 - limit the number of retries;
 - if retries are exceeded, thaw and return an error;
 - don't retry (or read the state back) on THAW.

I played a lot with various reproducers for this bug, including

 - parallel runc execs and runc pause/resumes
 - parallel runc execs and runc --systemd-cgroup update
   (the latter performs freeze/unfreeze);
 - continuously running /bin/printf inside container
   in parallel with runc pause/resume;
 - running pthread bomb (from criu test suite) in parallel
   with runc pause/resume;

and I was not able to make freeze work 100%, meaning sometimes
runc pause fails, or runc --systemd-cgroup update produces a warning.

With that said, it's still a big improvement over the previous
state of affairs where container is stuck in FREEZING state,
and GetState() (and all its users) are also stuck.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-01 13:54:00 -08:00
Sebastiaan van Stijn c4bc3b080e Remove "PatchAndLoad" stub as it's not used without seccomp enabled
This function is called by `InitSeccomp`, but only when compiled
with seccomp (and cgo) enabled, so should not be needed for other
situations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-01 22:01:59 +01:00
Kir Kolyshkin 6c85f6389e Merge pull request #2775 from cyphar/fix-build
cgroupfs: cpuset: fix broken build
2021-02-01 09:02:21 -08:00
Aleksa Sarai 4074b47975 merge branch 'pr-2636'
Kenta Tada (1):
  libcontainer/intelrdt: adjust the file mode

LGTMs: @AkihiroSuda @cyphar
Closes #2636
2021-02-01 20:50:25 +11:00
Akihiro Suda 2046f264ca Merge pull request #2755 from kolyshkin/numa-stat
libct/cg/fs: getPageUsageByNUMA: rewrite/optimize, fix panic, add more tests
2021-02-01 13:49:53 +09:00
Aleksa Sarai 6ddfaa5e95 cgroupfs: cpuset: fix broken build
The merge 6eed6e5795 broke the build because ab27e12ceb ("Implement
GetStat for cpuset cgroup.") dropped the errors import which was used by
c85cd2b325 ("libct/cg/fs/cpuset: don't parse mountinfo") and the CI
wasn't retriggered.

Fix this by just importing "github.com/pkg/errors" again.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-02-01 14:31:47 +11:00
Aleksa Sarai 091dd32dd1 merge branch 'pr-2607'
Sebastiaan van Stijn (1):
  libcontainer: move capabilities to separate package

LGTMs: @AkihiroSuda @cyphar
Closes #2607
2021-02-01 14:26:17 +11:00
Aleksa Sarai 6eed6e5795 merge branch 'pr-2599'
Kir Kolyshkin (4):
  libct/cgroups/fs/cpuset: don't use MkdirAll
  libct/cg/fs/cpuset: don't parse mountinfo
  libct/cg/fs.getCgroupRoot: reuse (cached) cgroup mountinfo
  libct/cgroups/v1_utils: implement mountinfo cache

LGTMs: @AkihiroSuda @cyphar
Closes #2599
2021-02-01 11:04:11 +11:00
Kir Kolyshkin c531a6f26a Merge pull request #2750 from cyphar/seccomp-patched-bpf
seccomp: prepend -ENOSYS stub to all filters
2021-01-31 11:54:41 -08:00
Akihiro Suda e7bd1fb10a Merge pull request #2717 from kolyshkin/check-proc-opt
libct/checkProcMounts: optimize
2021-01-29 17:32:45 +09:00
Mrunal Patel b8c2093338 Merge pull request #2738 from kolyshkin/unit-verbose
ci/unit tests: decrease verbosity
2021-01-28 15:34:06 -08:00
Aleksa Sarai 4160d74338 seccomp: add enosys unit tests
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-01-28 23:11:28 +11:00
Aleksa Sarai 7a8d7162f9 seccomp: prepend -ENOSYS stub to all filters
Having -EPERM is the default was a fairly significant mistake from a
future-proofing standpoint in that it makes any new syscall return a
non-ignorable error (from glibc's point of view). We need to correct
this now because faccessat2(2) is something glibc critically needs to
have support for, but they're blocked on container runtimes because we
return -EPERM unconditionally (leading to confusion in glibc). This is
also a problem we're probably going to keep running into in the future.

Unfortunately there are several issues which stop us from having a clean
solution to this problem:

 1. libseccomp has several limitations which require us to emulate
    behaviour we want:

    a. We cannot do logic based on syscall number, meaning we cannot
       specify a "largest known syscall number";
    b. libseccomp doesn't know in which kernel version a syscall was
       added, and has no API for "minimum kernel version" so we cannot
       simply ask libseccomp to generate sane -ENOSYS rules for us.
    c. Additional seccomp rules for the same syscall are not treated as
       distinct rules -- if rules overlap, seccomp will merge them. This
       means we cannot add per-syscall -EPERM fallbacks;
    d. There is no inverse operation for SCMP_CMP_MASKED_EQ;
    e. libseccomp does not allow you to specify multiple rules for a
       single argument, making it impossible to invert OR rules for
       arguments.

 2. The runtime-spec does not have any way of specifying:

    a. The errno for the default action;
    b. The minimum kernel version or "newest syscall at time of profile
       creation"; nor
    c. Which syscalls were intentionally excluded from the allow list
       (weird syscalls that are no longer used were excluded entirely,
       but Docker et al expect those syscalls to get EPERM not ENOSYS).

 3. Certain syscalls should not return -ENOSYS (especially only for
    certain argument combinations) because this could also trigger glibc
    confusion. This means we have to return -EPERM for certain syscalls
    but not as a global default.

 4. There is not an obvious (and reasonable) upper limit to syscall
    numbers, so we cannot create a set of rules for each syscall above
    the largest syscall number in libseccomp. This means we must handle
    inverse rules as described below.

 5. Any syscall can be specified multiple times, which can make
    generation of hotfix rules much harder.

As a result, we have to work around all of these things by coming up
with a heuristic to stop the bleeding. In the future we could hopefully
improve the situation in the runtime-spec and libseccomp.

The solution applied here is to prepend a "stub" filter which returns
-ENOSYS if the requested syscall has a larger syscall number than any
syscall mentioned in the filter. The reason for this specific rule is
that syscall numbers are (roughly) allocated sequentially and thus newer
syscalls will (usually) have a larger syscall number -- thus causing our
filters to produce -ENOSYS if the filter was written before the syscall
existed.

Sadly this is not a perfect solution because syscalls can be added
out-of-order and the syscall table can contain holes for several
releases. Unfortuntely we do not have a nicer solution at the moment
because there is no library which provides information about which Linux
version a syscall was introduced in. Until that exists, this workaround
will have to be good enough.

The above behaviour only happens if the default action is a blocking
action (in other words it is not SCMP_ACT_LOG or SCMP_ACT_ALLOW). If the
default action is permissive then we don't do any patching.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-01-28 23:11:22 +11:00
Kir Kolyshkin 5ef136ff78 Merge pull request #2763 from zhsj/fix-32
Fix int overflow in test on 32 bit system
2021-01-27 11:37:33 -08:00
Aleksa Sarai 346f87fec1 merge branch 'pr-2715'
Kir Kolyshkin (3):
  tests/int/mounts.bats: cleanup
  tests/int/mount.bats: reformat
  runc run: resolve tmpfs mount dest in container scope

LGTMs: @AkihiroSuda @cyphar
Closes #2715
2021-01-27 21:50:11 +11:00
Akihiro Suda 6721470a9e Merge pull request #2660 from kinvolk/mauricio/fix_unittests
libcontainer/configs: improve unit tests
2021-01-27 13:05:26 +09:00
Mrunal Patel be30b6e5ac Merge pull request #2725 from AkihiroSuda/fix-2724
systemd: fix rootful-in-userns regression
2021-01-26 11:28:47 -08:00
Mauricio Vásquez 2be806d139 libcontainer/configs: improve CommandHook unit tests
Test that CommandHook actually executes a new process with the given env
variables, parameters and json state.

This commit also solves an issue with the previous approach that was calling
'os.Exit(0)' failing to signal test failures.

Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
2021-01-26 13:01:41 -05:00
Shengjing Zhu f4d153b086 Fix int overflow in test on 32 bit system
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2021-01-24 16:37:32 +08:00
Mrunal Patel c69ae759fb Merge pull request #2716 from kolyshkin/fix-warn
libct: suppress bogus "unable to terminate" warnings
2021-01-21 21:12:17 -08:00
Kir Kolyshkin 4e98eec19c libct/cg: demote "systemd is too old" to debug
A recent commit a35cad3b22 added warnings about systemd being too
old. While those warnings are valid, they break some existing tests,
and also don't add much value to a user (IOW no one is going to upgrade
systemd because runc says it's old).

Demote those to warnings.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-21 11:28:51 -08:00
Kir Kolyshkin c7357aaddb libct/cg/ebpf/testDeviceFilter: rm verbose logging
These tests are quite verbose, it was probably good for development but
seems excessive for CI:

> === RUN   TestDeviceFilter_Nil
>     devicefilter_test.go:29: TestDeviceFilter_Nil: devices: []
>         	 0: LdXMemW dst: r2 src: r1 off: 0 imm: 0
>         	 1: And32Imm dst: r2 imm: 65535
>         	 2: LdXMemW dst: r3 src: r1 off: 0 imm: 0
>         	 3: RSh32Imm dst: r3 imm: 16
>         	 4: LdXMemW dst: r4 src: r1 off: 4 imm: 0
>         	 5: LdXMemW dst: r5 src: r1 off: 8 imm: 0
>         block-0:
>         	 6: Mov32Imm dst: r0 imm: 0
>         	 7: Exit
> --- PASS: TestDeviceFilter_Nil (0.00s)

... and so on

Remove t.Logf.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-21 10:33:25 -08:00
Mrunal Patel 2adbc66b71 Merge pull request #2727 from kolyshkin/cpuset
libc/cg: convert r.CPU.Cpus/Mems to systemd props
2021-01-20 21:25:52 -08:00
Kir Kolyshkin d9751a9b36 Merge pull request #2408 from piowag/cpuset_getstats
Add cpuset statistics
2021-01-20 19:52:56 -08:00
Kir Kolyshkin 6a9f5ac9d4 libct/cg/fs: fix a linter warning
It was already explained why we ignore the error, so let's ignore this
deliberately.

This fixes

> name.go:22:7: Error return value of `join` is not checked (errcheck)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-20 16:47:52 -08:00
Kir Kolyshkin 63c44e27f6 libct/cg/fs: getPageUsageByNUMA: rewrite/optimize
Rewrite getPageUsageByNUMA

1. Be less strict to unknown contents, i.e. skip it. This makes the
   function more future-proof. Before this commit, if a line like
   "a=b" is encountered, the function returns an error, which is
   propagated all the way up to and returned by (CgroupManager).GetStats.

2. Be more strict to contents it recognizes, i.e. return an error.
   In case the first field in the line is recognized (e.g. "total=123",
   the rest of the line should be in format "N<id>=<value> ...".

3. Optimize. Before this commit, addNUMAStatsByType was called for every
   item in the line, which is excessive and might even be slow in case
   there are many NUMA nodes. It is enough to look up the field once.

4. Remove a bunch of global numaNode* and numaStat* constants. Those
   were used by only one function, and it does not make sense to have
   them defined globally. Some were moved to the function, some were
   eliminated entirely.

5. Improve readability and added code comments.

Finally, add some test cases for good and bad contents.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-20 16:47:02 -08:00
acetang e9248dd5e6 cgroup: fix panic in parse memory.numa_stat
strings.SplitN not always return N fields if not staify, sometimes
cgroup interface add some custom fields make parse memory.numa_stat
fails, it will case panic

Signed-off-by: acetang <aceapril@126.com>
2021-01-20 12:29:58 -08:00
Kir Kolyshkin 426aa416b2 libct/int/TestExecInTTY: skip
This test is racy and so far I can't figure out how to fix it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-19 09:40:16 -08:00
Kir Kolyshkin c30cd3cddd libct/int/TestExecInTTY: fix error reporting
As buf is instantiated outside the loop, it is appended to,
so if/once an error happens, it contains the output of all previous
iterations. Not a big problem but looks a bit untidy.

Move the declaration to inside the loop.

Fixes: 06a684d6a7
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-19 09:40:16 -08:00
Kir Kolyshkin dac0c1e34a console.ClearONLCR: move it back
This reverts most of commit 24c05b7, as otherwise it causes
a few regressions (docker cli, TestDockerSwarmSuite/TestServiceLogsTTY).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-19 09:39:54 -08:00
Piotr Wagner ab27e12ceb Implement GetStat for cpuset cgroup.
Co-authored-by: Piotr Wagner <piotr.wagner@intel.com>
Signed-off-by: Paweł Szulik <pawel.szulik@intel.com>
2021-01-19 18:02:11 +01:00
Kir Kolyshkin 657a24ce01 libct/cg/TestGetHugePageSizeImpl: only log errors
This:

> === RUN   TestGetHugePageSizeImpl
>     utils_test.go:504: (input [hugepages-akB], error strconv.Atoi: parsing "a": invalid syntax)

feels like an error but it's not.

Only log errors.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-14 10:38:59 -08:00
Kir Kolyshkin 3394e37405 libct/cg/sd/TestRangeToBits: be less verbose
As we run unit tests with -v, this case produces lots of output
which was handy while working on the code, but now it's more
like noise:

=== RUN   TestRangeToBits
    cpuset_test.go:43: case: ""
    cpuset_test.go:46:    got error: empty value
    cpuset_test.go:43: case: "0"
    cpuset_test.go:53:    expected [1], got [1]
    cpuset_test.go:43: case: "1"
    cpuset_test.go:53:    expected [2], got [2]
    cpuset_test.go:43: case: "0-1"
    cpuset_test.go:53:    expected [3], got [3]
    cpuset_test.go:43: case: "0,1"
    cpuset_test.go:53:    expected [3], got [3]
    cpuset_test.go:43: case: ",0,1,"
    cpuset_test.go:53:    expected [3], got [3]
    cpuset_test.go:43: case: "0-3"
    cpuset_test.go:53:    expected [15], got [15]
    cpuset_test.go:43: case: "0,1,2-3"
    cpuset_test.go:53:    expected [15], got [15]
    cpuset_test.go:43: case: "4-7"
    cpuset_test.go:53:    expected [240], got [240]
    cpuset_test.go:43: case: "0-7"
    cpuset_test.go:53:    expected [255], got [255]
    cpuset_test.go:43: case: "0-15"
    cpuset_test.go:53:    expected [255 255], got [255 255]
    cpuset_test.go:43: case: "16"
    cpuset_test.go:53:    expected [1 0 0], got [1 0 0]
    cpuset_test.go:43: case: "0-3,32-33"
    cpuset_test.go:53:    expected [3 0 0 0 15], got [3 0 0 0 15]
    cpuset_test.go:43: case: "1, 2, 1-2"
    cpuset_test.go:53:    expected [6], got [6]
    cpuset_test.go:43: case: "    , 1   , 3  ,  5-7,\t"
    cpuset_test.go:53:    expected [234], got [234]
    cpuset_test.go:43: case: "128-130,1"
    cpuset_test.go:53:    expected [7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2], got [7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2]
    cpuset_test.go:43: case: "-"
    cpuset_test.go:46:    got error: strconv.ParseUint: parsing "": invalid syntax
    cpuset_test.go:43: case: "1-"
    cpuset_test.go:46:    got error: strconv.ParseUint: parsing "": invalid syntax
    cpuset_test.go:43: case: "-3"
    cpuset_test.go:46:    got error: strconv.ParseUint: parsing "": invalid syntax
    cpuset_test.go:43: case: "54-53"
    cpuset_test.go:46:    got error: invalid range: 54-53
    cpuset_test.go:43: case: "1 - 2"
    cpuset_test.go:46:    got error: strconv.ParseUint: parsing "1 ": invalid syntax
--- PASS: TestRangeToBits (0.00s)

Only log errors.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-14 10:34:32 -08:00
Akihiro Suda c751ba3fd9 systemd: show more helpful error
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-01-14 14:56:37 +09:00
Kir Kolyshkin a35cad3b22 libct/cg/sd/v2: warn about old systemd
1. Add a check to unifiedResToSystemdProps that systemd is recent enough
   to support AllowedCPUs/AllowedMemoryNodes unit properties, and skip
   setting the property if it is not supported.

   Note that this is not an error as the setting is still applied to
   the underlying cgroupfs -- it's just systemd unit property that is
   being skipped.

2. In all the places we skip an unsupported property, warn about it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-13 19:29:50 -08:00
Kir Kolyshkin 03b512e511 libc/cg: convert r.CPU.Cpus/Mems to systemd props
Support for systemd properties AllowedCPUs and AllowedMemoryNodes
was added by commit 13afa58d0e, but only for unified resources
of systemd v2 driver.

This adds support for Cpu.Cpus and Cpu.Mems resources to
both systemd v1 and v2 cgroup drivers.

An integration test is added to check that the settings work.

[v2: check for systemd version]
[v3: same in the test]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-13 19:28:54 -08:00
Kir Kolyshkin eee425f5a0 libct/cg/sd/systemdVersion: don't return error
As the caller of this function just logs the error, it does not make
sense to pass it. Instead, log it (once) and return -1.

This is a preparation for the second user.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-13 18:00:41 -08:00
Mrunal Patel dbbe7e60c7 Merge pull request #2722 from thaJeztah/warn_freeze
libcontainer: signalAllProcesses(): log warning when failing to thaw
2021-01-13 16:42:42 -08:00
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 06a684d6a7 libct/int/TestExecInTTY: repeat the test 300 times
This is to increase the chance to hit the recently fixed race.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:34:46 -08:00
Kir Kolyshkin fedaa2abed TestExecInTTY: simplify, improve error reporting
Simplify the tty code by using 1 goroutine instead of 2.

Improve error reporting by wrapping the errors.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:34:41 -08:00
Kir Kolyshkin 24c05b71fa tty: fix ClearONLCR race
The TestExecInTTY test case is sometimes failing like this:

> execin_test.go:332: unexpected carriage-return in output "PID USER TIME COMMAND\r\n 1 root 0:00 cat\r\n 7 root 0:00 ps\r\n"

or this:

> execin_test.go:332: unexpected carriage-return in output "PID USER TIME COMMAND\r\n 1 root 0:00 cat\n 7 root 0:00 ps\n"

(this is easy to repro with `go test -run TestExecInTTY -count 1000`).

This is caused by a race between

 - an Init() (in this case it is is (*linuxSetnsInit.Init(), but
   (*linuxStandardInit).Init() is no different in this regard),
   which creates a pty pair, sends pty master to runc, and execs
   the container process,

and

 - a parent runc process, which receives the pty master fd and calls
   ClearONLCR() on it.

One way of fixing it would be to add a synchronization mechanism
between these two, so Init() won't exec the process until the parent
sets the flag. This seems excessive, though, as we can just move
the ClearONLCR() call to Init(), putting it right after console.NewPty().

Note that bug only happens in the TestExecInTTY test case, but
from looking at the code it seems like it can happen in runc run
or runc exec, too.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:33:00 -08:00
Sebastiaan van Stijn 039c47ab82 libcontainer: signalAllProcesses(): log warning when failing to thaw
I noticed this was the only place in this function where we didn't
handle errors on freezing/thawing. Logging as a warning, consistent
with the other cases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-01-07 11:45:11 +01:00
Sebastiaan van Stijn 1897217731 libcontainer: move capabilities to separate package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-01-07 11:42:01 +01:00
Kir Kolyshkin 692fab0936 libct/checkProcMounts: optimize
Commit 9c1242ecb ("Add white list for bind mount chec", Jan 6 2016)
added a set of entries under /proc which we allow to be mounted to,
for the benefit of lxcfs-like fuse-backed hack to have container's
own version of /proc/meminfo etc.

For some reason, the allow list check is performed at the very
beginning of the function, which is not optimal.

Move the check to the end -- at this point in the code we already
know we're under /proc, so it make sense to consult the allow list.

This makes the code slightly more logical and hopefully slightly faster.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 15:02:38 -08:00
Kir Kolyshkin 72f463891d libct: add TODO about os.ErrProcessDone
This is a new variable added by go 1.16 so we'll have to wait
until 1.16 is minimally supported version, thus TODO for now.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 14:57:39 -08:00
Kir Kolyshkin d7df30181b libct: suppress bogus "unable to terminate" warnings
While working on a test case for [1], I got the following warning:

> level=warning msg="unable to terminate initProcess" error="exit status 1"

Obviously, the warning is bogus since the initProcess is terminated.

This is happening because terminate() can return errors from either
Kill() or Wait(), and the latter returns an error if the process has
not finished successfully (i.e. exit status is not 0 or it was killed).

Check for a particular error type and filter out those errors.

[1] https://github.com/opencontainers/runc/issues/2683

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 14:57:39 -08:00
Kir Kolyshkin 637f82d6b8 runc run: resolve tmpfs mount dest in container scope
In case a tmpfs mount path contains absolute symlinks, runc errors out
because those symlinks are resolved in the host (rather than container)
filesystem scope.

The fix is similar to that for bind mounts -- resolve the destination
in container rootfs scope using securejoin, and use the resolved path.

A simple integration test case is added to prevent future regressions.

Fixes https://github.com/opencontainers/runc/issues/2683.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 14:57:02 -08:00