Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit b64310a

Browse files
committed
Update restrict.Restrict to both show the error message when failing to mount /dev/null over /proc/kcore, and to ignore "not exists" errors while doing so (for when CONFIG_PROC_KCORE=n in the kernel)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
1 parent 68de553 commit b64310a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

security/restrict/restrict.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package restrict
44

55
import (
66
"fmt"
7+
"os"
78
"syscall"
89

910
"github.com/dotcloud/docker/pkg/system"
@@ -18,8 +19,8 @@ func Restrict(mounts ...string) error {
1819
return fmt.Errorf("unable to remount %s readonly: %s", dest, err)
1920
}
2021
}
21-
if err := system.Mount("/dev/null", "/proc/kcore", "", syscall.MS_BIND, ""); err != nil {
22-
return fmt.Errorf("unable to bind-mount /dev/null over /proc/kcore")
22+
if err := system.Mount("/dev/null", "/proc/kcore", "", syscall.MS_BIND, ""); err != nil && !os.IsNotExist(err) {
23+
return fmt.Errorf("unable to bind-mount /dev/null over /proc/kcore: %s", err)
2324
}
2425
return nil
2526
}

0 commit comments

Comments
 (0)