Skip to content

Commit d87da59

Browse files
crosbymichaeljessfraz
authored andcommitted
Prevent write access to /proc/asound
Signed-off-by: Michael Crosby <[email protected]> Conflicts: integration-cli/docker_cli_run_test.go
1 parent 74bfa36 commit d87da59

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

daemon/execdriver/native/template/default_template.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ func New() *configs.Config {
8484
"/proc/kcore",
8585
},
8686
ReadonlyPaths: []string{
87-
"/proc/sys", "/proc/sysrq-trigger", "/proc/irq", "/proc/bus",
87+
"/proc/asound",
88+
"/proc/bus",
89+
"/proc/irq",
90+
"/proc/sys",
91+
"/proc/sysrq-trigger",
8892
},
8993
}
9094

integration-cli/docker_cli_run_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,3 +3056,24 @@ func (s *DockerSuite) TestRunPidHostWithChildIsKillable(c *check.C) {
30563056
c.Fatal("Kill container timed out")
30573057
}
30583058
}
3059+
3060+
func TestRunWithTooSmallMemoryLimit(t *testing.T) {
3061+
defer deleteAllContainers()
3062+
// this memory limit is 1 byte less than the min, which is 4MB
3063+
// https://github.com/docker/docker/blob/v1.5.0/daemon/create.go#L22
3064+
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-m", "4194303", "busybox"))
3065+
if err == nil || !strings.Contains(out, "Minimum memory limit allowed is 4MB") {
3066+
t.Fatalf("expected run to fail when using too low a memory limit: %q", out)
3067+
}
3068+
3069+
logDone("run - can't set too low memory limit")
3070+
}
3071+
3072+
func TestRunWriteToProcAsound(t *testing.T) {
3073+
defer deleteAllContainers()
3074+
code, err := runCommand(exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "echo 111 >> /proc/asound/version"))
3075+
if err == nil || code == 0 {
3076+
t.Fatal("standard container should not be able to write to /proc/asound")
3077+
}
3078+
logDone("run - ro write to /proc/asound")
3079+
}

0 commit comments

Comments
 (0)