Skip to content

Commit a8d7eb7

Browse files
authored
Merge pull request #1314 from runcom/overlay-mounts
libcontainer: rootfs_linux: support overlayfs
2 parents b263a43 + ca14e7b commit a8d7eb7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libcontainer/rootfs_linux.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
313313
}
314314
}
315315
default:
316+
// ensure that the destination of the mount is resolved of symlinks at mount time because
317+
// any previous mounts can invalidate the next mount's destination.
318+
// this can happen when a user specifies mounts within other mounts to cause breakouts or other
319+
// evil stuff to try to escape the container's rootfs.
320+
var err error
321+
if dest, err = symlink.FollowSymlinkInScope(filepath.Join(rootfs, m.Destination), rootfs); err != nil {
322+
return err
323+
}
324+
if err := checkMountDestination(rootfs, dest); err != nil {
325+
return err
326+
}
327+
// update the mount with the correct dest after symlinks are resolved.
328+
m.Destination = dest
316329
if err := os.MkdirAll(dest, 0755); err != nil {
317330
return err
318331
}

0 commit comments

Comments
 (0)