On Ubuntu and Debian there is a sysctl which allows to block
clone(CLONE_NEWUSER) via "sysctl kernel.unprivileged_userns_clone=0"
for unprivileged users that do not have CAP_SYS_ADMIN.
See: https://lists.ubuntu.com/archives/kernel-team/2016-January/067926.html
The DockerSuite.TestRunSeccompUnconfinedCloneUserns testcase fails if
"kernel.unprivileged_userns_clone" is set to 0:
docker_cli_run_unix_test.go:1040:
c.Fatalf("expected clone userns with --security-opt seccomp=unconfined
to succeed, got %s: %v", out, err)
... Error: expected clone userns with --security-opt seccomp=unconfined
to succeed, got clone failed: Operation not permitted
: exit status 1
So add a check and skip the testcase if kernel.unprivileged_userns_clone is 0.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
| ... | ... |
@@ -1032,7 +1032,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *check.C) {
|
| 1032 | 1032 |
// TestRunSeccompUnconfinedCloneUserns checks that |
| 1033 | 1033 |
// 'docker run --security-opt seccomp=unconfined syscall-test' allows creating a userns. |
| 1034 | 1034 |
func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *check.C) {
|
| 1035 |
- testRequires(c, SameHostDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace) |
|
| 1035 |
+ testRequires(c, SameHostDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace, unprivilegedUsernsClone) |
|
| 1036 | 1036 |
|
| 1037 | 1037 |
// make sure running w privileged is ok |
| 1038 | 1038 |
runCmd := exec.Command(dockerBinary, "run", "--security-opt", "seccomp=unconfined", "syscall-test", "userns-test", "id") |
| ... | ... |
@@ -3,6 +3,9 @@ |
| 3 | 3 |
package main |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "io/ioutil" |
|
| 7 |
+ "strings" |
|
| 8 |
+ |
|
| 6 | 9 |
"github.com/docker/docker/pkg/sysinfo" |
| 7 | 10 |
) |
| 8 | 11 |
|
| ... | ... |
@@ -99,6 +102,16 @@ var ( |
| 99 | 99 |
}, |
| 100 | 100 |
"Test requires that bridge-nf-call-ip6tables support be enabled in the daemon.", |
| 101 | 101 |
} |
| 102 |
+ unprivilegedUsernsClone = testRequirement{
|
|
| 103 |
+ func() bool {
|
|
| 104 |
+ content, err := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
|
|
| 105 |
+ if err == nil && strings.Contains(string(content), "0") {
|
|
| 106 |
+ return false |
|
| 107 |
+ } |
|
| 108 |
+ return true |
|
| 109 |
+ }, |
|
| 110 |
+ "Test cannot be run with 'sysctl kernel.unprivileged_userns_clone' = 0", |
|
| 111 |
+ } |
|
| 102 | 112 |
) |
| 103 | 113 |
|
| 104 | 114 |
func init() {
|