Skip to content

Commit 4fda64b

Browse files
author
Mrunal Patel
committed
Merge pull request #452 from hqhq/hq_bindmount_whitelist
Add white list for bind mount check
2 parents 5c46b9d + 9c1242e commit 4fda64b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

libcontainer/rootfs_linux.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ func checkMountDestination(rootfs, dest string) error {
299299
invalidDestinations := []string{
300300
"/proc",
301301
}
302+
// White list, it should be sub directories of invalid destinations
303+
validDestinations := []string{
304+
// These entries can be bind mounted by files emulated by fuse,
305+
// so commands like top, free displays stats in container.
306+
"/proc/cpuinfo",
307+
"/proc/diskstats",
308+
"/proc/meminfo",
309+
"/proc/stats",
310+
}
311+
for _, valid := range validDestinations {
312+
path, err := filepath.Rel(filepath.Join(rootfs, valid), dest)
313+
if err != nil {
314+
return err
315+
}
316+
if path == "." {
317+
return nil
318+
}
319+
}
302320
for _, invalid := range invalidDestinations {
303321
path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest)
304322
if err != nil {

0 commit comments

Comments
 (0)