|
@@ -2397,7 +2397,10 @@ func (s *DockerSuite) TestRunWriteToProcAsound(c *check.C) {
|
|
func (s *DockerSuite) TestRunReadProcTimer(c *check.C) {
|
|
func (s *DockerSuite) TestRunReadProcTimer(c *check.C) {
|
|
testRequires(c, NativeExecDriver)
|
|
testRequires(c, NativeExecDriver)
|
|
out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/timer_stats")
|
|
out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/timer_stats")
|
|
- if err != nil || code != 0 {
|
|
|
|
|
|
+ if code != 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
c.Fatal(err)
|
|
c.Fatal(err)
|
|
}
|
|
}
|
|
if strings.Trim(out, "\n ") != "" {
|
|
if strings.Trim(out, "\n ") != "" {
|
|
@@ -2414,7 +2417,10 @@ func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/latency_stats")
|
|
out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/latency_stats")
|
|
- if err != nil || code != 0 {
|
|
|
|
|
|
+ if code != 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
c.Fatal(err)
|
|
c.Fatal(err)
|
|
}
|
|
}
|
|
if strings.Trim(out, "\n ") != "" {
|
|
if strings.Trim(out, "\n ") != "" {
|
|
@@ -2422,6 +2428,24 @@ func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (s *DockerSuite) TestRunReadFilteredProc(c *check.C) {
|
|
|
|
+ testRequires(c, Apparmor)
|
|
|
|
+
|
|
|
|
+ testReadPaths := []string{
|
|
|
|
+ "/proc/latency_stats",
|
|
|
|
+ "/proc/timer_stats",
|
|
|
|
+ "/proc/kcore",
|
|
|
|
+ }
|
|
|
|
+ for i, filePath := range testReadPaths {
|
|
|
|
+ name := fmt.Sprintf("procsieve-%d", i)
|
|
|
|
+ shellCmd := fmt.Sprintf("exec 3<%s", filePath)
|
|
|
|
+
|
|
|
|
+ if out, exitCode, err := dockerCmdWithError("run", "--privileged", "--security-opt", "apparmor:docker-default", "--name", name, "busybox", "sh", "-c", shellCmd); err == nil || exitCode == 0 {
|
|
|
|
+ c.Fatalf("Open FD for read should have failed with permission denied, got: %s, %v", out, err)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func (s *DockerSuite) TestMountIntoProc(c *check.C) {
|
|
func (s *DockerSuite) TestMountIntoProc(c *check.C) {
|
|
testRequires(c, NativeExecDriver)
|
|
testRequires(c, NativeExecDriver)
|
|
_, code, err := dockerCmdWithError("run", "-v", "/proc//sys", "busybox", "true")
|
|
_, code, err := dockerCmdWithError("run", "-v", "/proc//sys", "busybox", "true")
|
|
@@ -2515,6 +2539,7 @@ func (s *DockerSuite) TestRunWriteFilteredProc(c *check.C) {
|
|
"/proc/sys/kernel/modprobe",
|
|
"/proc/sys/kernel/modprobe",
|
|
"/proc/sys/kernel/core_pattern",
|
|
"/proc/sys/kernel/core_pattern",
|
|
"/proc/sysrq-trigger",
|
|
"/proc/sysrq-trigger",
|
|
|
|
+ "/proc/kcore",
|
|
}
|
|
}
|
|
for i, filePath := range testWritePaths {
|
|
for i, filePath := range testWritePaths {
|
|
name := fmt.Sprintf("writeprocsieve-%d", i)
|
|
name := fmt.Sprintf("writeprocsieve-%d", i)
|