Commit Graph

3169 Commits

Author SHA1 Message Date
Aleksa Sarai 6e97f3ad69
tests: mask: use test paths rather than /sys
In certain circumstances (such as the rootless containers patchset), it
is not possible to test things using /sys/firmware. In addition, we
should be testing our own functionality rather than testing protection
against /sys attacks (for which the system might already have extra
protections).

Instead, just make some fake paths in the rootfs that we then mask.
Oddly I noticed that one of the errors changed when doing this (because
before we tested removing a file from /sys/firmware which is -EPERM). So
the old test was broken.

Fixes: 53179559a1 ("MaskPaths: support directory")
Fixes: #1068
Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-10-19 05:59:50 +11:00
Andrew Vagin 88b4c4851e Merge pull request #1120 from cyphar/fix-gofmt
checkpoint: fix gofmt
2016-10-18 23:56:48 +05:00
Aleksa Sarai 38560a0316
checkpoint: fix gofmt
Fixes: a60040c62d ("Container must not checkpoint in created state")
Fixes: #1076
Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-10-19 05:37:24 +11:00
Aleksa Sarai e3cd191acc
nsenter: un-split clone(cloneflags) for RHEL
Without this patch applied, RHEL's SELinux policies cause container
creation to not really work. Unfortunately this might be an issue for
rootless containers (opencontainers/runc#774) but we'll cross that
bridge when we come to it.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-10-18 18:26:27 +11:00
Aleksa Sarai bf77e5976a
merge branch 'pr-1118'
Closes: #1118
LGTMs: @cyphar @hqhq
2016-10-18 18:17:31 +11:00
Wang Long ed6c5c038c update the man for runc delete command
This patch also change the description in delete.go in order to
keep consistent with the mannual.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-18 12:18:10 +08:00
Michael Crosby fcc40b7a63 Remove panic from init
Print the error message to stderr if we are unable to return it back via
the pipe to the parent process.  Also, don't panic here as it is most
likely a system or user error and not a programmer error.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-10-17 15:54:51 -07:00
Mrunal Patel 0259c00a35 Merge pull request #1105 from keloyang/check-kill-signal-num
Add num check for kill command
2016-10-17 15:15:28 -07:00
Mrunal Patel 4161f2a63b Merge pull request #1115 from rajasec/filemode-panic
Fixing runc panic for missing file mode
2016-10-17 15:01:49 -07:00
Mrunal Patel 30a122d068 Merge pull request #1112 from rhatdan/romount
Add support for r/o mount labels
2016-10-17 14:45:32 -07:00
Michael Crosby 4dcc0466e2 Merge pull request #1074 from datawolf/multi-containers
start multi-containers with `runc start` command
2016-10-17 14:31:04 -07:00
Dan Walsh 6932807107 Add support for r/o mount labels
We need support for read/only mounts in SELinux to allow a bunch of
containers to share the same read/only image.  In order to do this
we need a new label which allows container processes to read/execute
all files but not write them.

Existing mount label is either shared write or private write.  This
label is shared read/execute.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-10-17 16:56:42 -04:00
rajasec 528bf3718d ps error logging improvement
Signed-off-by: rajasec <rajasec79@gmail.com>

ps error logging improvement

Signed-off-by: rajasec <rajasec79@gmail.com>
2016-10-17 20:50:33 +05:30
Qiang Huang 509ddd6f11 Merge pull request #1075 from datawolf/pause-resume-multi-containers
pause and resume multi-containers
2016-10-17 22:53:22 +08:00
Wang Long 2f5c0afbbc pause and resume multi-containers
With this patch, `runc pasue` and `runc resume` can
pause and resume multi-containers.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-17 19:44:08 +08:00
Qiang Huang a6284a7bdb Merge pull request #1116 from rajasec/hugetlb-panic
Fixing runc panic during hugetlb pages
2016-10-17 13:55:59 +08:00
rajasec 034cba6af0 Fixing runc panic for missing file mode
Signed-off-by: rajasec <rajasec79@gmail.com>

Fixing runc panic for missing file mode

Signed-off-by: rajasec <rajasec79@gmail.com>
2016-10-16 20:39:44 +05:30
Aleksa Sarai 7be6edaa60
merge branch 'pr-1114'
LGTMs: @hqhq @cyphar
Closes: #1114
2016-10-16 22:27:15 +11:00
rajasec 4b263c9594 Fixing runc panic during hugetlb pages
Signed-off-by: rajasec <rajasec79@gmail.com>

Fixing runc panic during hugetlb pages

Signed-off-by: rajasec <rajasec79@gmail.com>
2016-10-15 19:47:33 +05:30
Mrunal Patel 3abefdff18 Merge pull request #1109 from rhatdan/dupsec
DupSecOpt needs to match InitLabels
2016-10-14 08:18:25 -07:00
Lei Jitang 1cd050244e Valide platform on loading config.json
run an arm64 image on an amd64 platform, it will failed with
````
panic: standard_init_linux.go:175: exec user process caused "exec format error" [recovered]
        panic: standard_init_linux.go:175: exec user process caused "exec format error"

goroutine 1 [running, locked to thread]:
panic(0x7e7e40, 0xc820124380)
        /usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/urfave/cli.HandleAction.func1(0xc8200c52f8)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:478 +0x38e
panic(0x7e7e40, 0xc820124380)
        /usr/local/go/src/runtime/panic.go:443 +0x4e9
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization.func1(0xc8200c4c08, 0xc8200220a0, 0xc8200c4d18)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:259 +0x136
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization(0xc82006c780, 0x7fb9124733f8, 0xc820124380)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:277 +0x5b1
main.glob.func8(0xc820090780, 0x0, 0x0)
        /home/lei/opencontainers/runc/main_unix.go:26 +0x68
reflect.Value.call(0x74ca00, 0x8fda40, 0x13, 0x844470, 0x4, 0xc8200c5278, 0x1, 0x1, 0x0, 0x0, ...)
        /usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0x74ca00, 0x8fda40, 0x13, 0xc8200c5278, 0x1, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/reflect/value.go:303 +0xb1
github.com/urfave/cli.HandleAction(0x74ca00, 0x8fda40, 0xc820090780, 0x0, 0x0)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:487 +0x2ee
github.com/urfave/cli.Command.Run(0x847330, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8dcec0, 0x51, 0x0, ...)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/command.go:191 +0xfec
github.com/urfave/cli.(*App).Run(0xc820001980, 0xc82000a100, 0x2, 0x2, 0x0, 0x0)
        /home/lei/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:240 +0xaa4
main.main()
        /home/lei/opencontainers/runc/main.go:137 +0xe24

````
instead of throwing panic on execing the container process, we should
throw the platform mismatch at the very beginning, it's much more
clear and can tell user what's wrong.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-10-14 02:53:37 -04:00
Dan Walsh 491cadac92 DupSecOpt needs to match InitLabels
At some point InitLabels was changed to look for SecuritOptions
separated by a ":" rather then an "=", but DupSecOpt was never
changed to match this default.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-10-13 16:10:29 -04:00
Daniel, Dao Quang Minh d186a7552b Merge pull request #1111 from keloyang/rpid-limit-check
tiny fix, add a null check for specs.Resources.Pids.Limit
2016-10-13 18:04:49 +01:00
Shukui Yang affc105264 tiny fix, add a null check for specs.Resources.Pids.Limit
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
2016-10-13 15:55:30 +08:00
Mrunal Patel 3b4ff53867 Merge pull request #1097 from keloyang/remove-tmp-bats
remove /tmp/bats from dev_runc
2016-10-12 11:07:56 -07:00
Qiang Huang ee992e5ff7 Merge pull request #1108 from dqminh/misspell
fix typos with misspell
2016-10-12 07:34:02 +02:00
Daniel Dao 1b876b0bf2 fix typos with misspell
pipe the source through https://github.com/client9/misspell. typos be gone!

Signed-off-by: Daniel Dao <dqminh89@gmail.com>
2016-10-11 23:22:48 +00:00
Daniel, Dao Quang Minh 8d505cb9dc Merge pull request #1107 from datawolf/fix-a-typo
just fix a typo
2016-10-12 00:15:51 +01:00
Daniel, Dao Quang Minh 89d025ff66 Merge pull request #1106 from xlgao-zju/tiny-fix
tiny fix
2016-10-12 00:15:35 +01:00
Wang Long 5eaa9ed5cd just fix a typo
Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-11 08:38:15 +00:00
Xianglin Gao 9df4847a23 tiny fix
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
2016-10-11 16:32:56 +08:00
Qiang Huang 010274f2f5 Merge pull request #1078 from datawolf/delete-command
Delete: exit with non zero if one of the containers encountered an error
2016-10-11 08:51:29 +02:00
Shukui Yang a367e4b95c Add num check for kill command
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
2016-10-11 14:15:04 +08:00
Qiang Huang 26ebd6ab63 Merge pull request #1102 from datawolf/Revert-simplify-ps-command
Revert "simplify ps command"
2016-10-11 03:53:28 +02:00
Wang Long 1a6391b03f Revert "simplify ps command"
This reverts commit 067ce21f7a.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-10 09:27:07 +08:00
Shukui Yang dba9253d2b remove /tmp/bats from dev_runc
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
2016-10-09 09:43:22 +08:00
Wang Long 74bfe500e4 start mulit-containers with `runc start` command
With this patch, `runc start` command can start mulit-containers
at one command this patch also checks the argument of the `start`
command.

root@ubuntu:# runc list
ID          PID         STATUS      BUNDLE         CREATED
a           0           stopped     /mycontainer   2016-09-23T08:56:42.754026567Z
b           62979       created     /mycontainer   2016-09-23T09:01:36.421976458Z
c           62993       running     /mycontainer   2016-09-23T09:01:38.105940389Z
d           63006       created     /mycontainer   2016-09-23T09:01:39.65441942Z
e           63020       created     /mycontainer   2016-09-23T09:01:40.989995515Z
root@ubuntu:# runc start
runc: "start" requires a minimum of 1 argument
root@ubuntu:# runc start a b c d e f
cannot start a container that has run and stopped
cannot start an already running container
container f is not exist
all or part of the containers start failed
root@ubuntu:# runc list
ID          PID         STATUS      BUNDLE         CREATED
a           0           stopped     /mycontainer   2016-09-23T08:56:42.754026567Z
b           62979       running     /mycontainer   2016-09-23T09:01:36.421976458Z
c           62993       running     /mycontainer   2016-09-23T09:01:38.105940389Z
d           63006       running     /mycontainer   2016-09-23T09:01:39.65441942Z
e           63020       running     /mycontainer   2016-09-23T09:01:40.989995515Z

Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-08 11:57:25 +08:00
Wang Long 7e38b37e7c Delete: exit with non zero if one of the containers encountered an error
Signed-off-by: Wang Long <long.wanglong@huawei.com>
2016-10-08 11:28:56 +08:00
Michael Crosby 45c30e75ab Merge pull request #784 from hqhq/hq_ps_following_up
Add integration test for ps command
2016-10-07 15:23:04 -07:00
Michael Crosby 2ad2cf7b28 Merge pull request #1092 from datawolf/simplify-ps-command
simplify ps command
2016-10-07 15:16:31 -07:00
Qiang Huang d1fc802264 Merge pull request #1095 from crosbymichael/kmem
Don't enable kernel mem if not set
2016-10-07 21:59:56 +02:00
Michael Crosby 11222ee1f1 Don't enable kernel mem if not set
Don't enable the kmem limit if it is not specified in the config.

Fixes #1083

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-10-07 10:02:19 -07:00
Aleksa Sarai b1eb19b4f3
merge branch 'pr-1084'
LGTMs: @mrunalp @cyphar

Closes #1084
2016-10-07 19:10:14 +11:00
Mrunal Patel c4e7f01c4b Add an integration test for tmpfs copy up
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2016-10-04 11:26:37 -07:00
Mrunal Patel c7406f7075 Support copyup mount extension for tmpfs mounts
If copyup is specified for a tmpfs mount, then the contents of the
underlying directory are copied into the tmpfs mounted over it.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2016-10-04 11:26:30 -07:00
Aleksa Sarai 2cd9c31b99
nsenter: guarantee correct user namespace ordering
Depending on your SELinux setup, the order in which you join namespaces
can be important. In general, user namespaces should *always* be joined
and unshared first because then the other namespaces are correctly
pinned and you have the right priviliges within them. This also is very
useful for rootless containers, as well as older kernels that had
essentially broken unshare(2) and clone(2) implementations.

This also includes huge refactorings in how we spawn processes for
complicated reasons that I don't want to get into because it will make
me spiral into a cloud of rage. The reasoning is in the giant comment in
clone_parent. Have fun.

In addition, because we now create multiple children with CLONE_PARENT,
we cannot wait for them to SIGCHLD us in the case of a death. Thus, we
have to resort to having a child kindly send us their exit code before
they die. Hopefully this all works okay, but at this point there's not
much more than we can do.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-10-04 16:17:55 +11:00
Aleksa Sarai ed053a740c
nsenter: specify namespace type in setns()
This avoids us from running into cases where libcontainer thinks that a
particular namespace file is a different type, and makes it a fatal
error rather than causing broken functionality.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-10-04 16:17:55 +11:00
Mrunal Patel 02f8fa7863 Merge pull request #1089 from mlaventure/fix-logging-on-error
Ensure we log into logrus on command error
2016-10-03 09:42:46 -07:00
Kenfe-Mickael Laventure 294d24fb1a Ensure we log into logrus on command error
`urfave/cli` now takes upon itself to log the error returned by the
command action directly. This means that by default the `--log` option
was ignored upon error.

This commit ensure that `urfave/cli.ErrWriter` will use logrus

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-10-03 08:01:09 -07:00
Mrunal Patel 7b1bcb3762 Merge pull request #1090 from crosbymichael/bind-root
Remove check for binding to /
2016-09-30 14:42:30 -07:00