Skip to content

Commit

Permalink
Add white list for bind mount chec
Browse files Browse the repository at this point in the history
Fixes: #400

It would be useful to use fuse to isolate proc info.

Signed-off-by: Qiang Huang <[email protected]>
  • Loading branch information
hqhq committed Jan 6, 2016
1 parent d97d5e8 commit 9c1242e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,24 @@ func checkMountDestination(rootfs, dest string) error {
invalidDestinations := []string{
"/proc",
}
// White list, it should be sub directories of invalid destinations
validDestinations := []string{
// These entries can be bind mounted by files emulated by fuse,
// so commands like top, free displays stats in container.
"/proc/cpuinfo",
"/proc/diskstats",
"/proc/meminfo",
"/proc/stats",
}
for _, valid := range validDestinations {
path, err := filepath.Rel(filepath.Join(rootfs, valid), dest)
if err != nil {
return err
}
if path == "." {
return nil
}
}
for _, invalid := range invalidDestinations {
path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest)
if err != nil {
Expand Down

0 comments on commit 9c1242e

Please sign in to comment.