Skip to content

Commit 636b664

Browse files
committed
linux: drop check for /proc as invalid dest
it is now allowed to bind mount /proc. This is useful for rootless containers when the PID namespace is shared with the host. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent ad0f525 commit 636b664

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libcontainer/rootfs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func checkMountDestination(rootfs, dest string) error {
413413
if err != nil {
414414
return err
415415
}
416-
if path == "." || !strings.HasPrefix(path, "..") {
416+
if path != "." && !strings.HasPrefix(path, "..") {
417417
return fmt.Errorf("%q cannot be mounted because it is located inside %q", dest, invalid)
418418
}
419419
}

libcontainer/rootfs_linux_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ import (
99
)
1010

1111
func TestCheckMountDestOnProc(t *testing.T) {
12-
dest := "/rootfs/proc/"
12+
dest := "/rootfs/proc/sys"
1313
err := checkMountDestination("/rootfs", dest)
1414
if err == nil {
1515
t.Fatal("destination inside proc should return an error")
1616
}
1717
}
1818

19+
func TestCheckMountDestOnProcChroot(t *testing.T) {
20+
dest := "/rootfs/proc/"
21+
err := checkMountDestination("/rootfs", dest)
22+
if err != nil {
23+
t.Fatal("destination inside proc when using chroot should not return an error")
24+
}
25+
}
26+
1927
func TestCheckMountDestInSys(t *testing.T) {
2028
dest := "/rootfs//sys/fs/cgroup"
2129
err := checkMountDestination("/rootfs", dest)

0 commit comments

Comments
 (0)