Skip to content

Commit 9cda583

Browse files
author
Mrunal Patel
authored
Merge pull request opencontainers#1832 from giuseppe/runc-drop-invalid-proc-destination-with-chroot
linux: drop check for /proc as invalid dest
2 parents 784b601 + 636b664 commit 9cda583

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
@@ -438,7 +438,7 @@ func checkMountDestination(rootfs, dest string) error {
438438
if err != nil {
439439
return err
440440
}
441-
if path == "." || !strings.HasPrefix(path, "..") {
441+
if path != "." && !strings.HasPrefix(path, "..") {
442442
return fmt.Errorf("%q cannot be mounted because it is located inside %q", dest, invalid)
443443
}
444444
}

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)