Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ func statfsToMountFlags(st unix.Statfs_t) int {

func (m *mountEntry) createOpenMountpoint(root *os.File) (Err error) {
rootfs := root.Name()
// The runtime spec says the destination is a path inside the container,
// but for legacy reasons (see commit 087caf69) a destination with the
// host rootfs path prefix is also accepted, and the prefix is stripped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a warning for such paths in 1.6 and remove those in 1.8?

unsafePath := pathrs.LexicallyStripRoot(rootfs, m.Destination)
dstFile, err := pathrs.OpenInRoot(root, unsafePath, unix.O_PATH)
defer func() {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/mounts.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ function test_mount_order() {
config_add_bind_mount "$PWD/bind-src/sym-a" "/mnt/x/y/z"
# Create a recursive bind-mount that uses part of the current tree in the
# container.
config_add_bind_mount "$rootfs/mnt/x" "$rootfs/mnt/x/y/z/x" "$ctr_src_opts"
config_add_bind_mount "$rootfs/mnt/x/y" "$rootfs/mnt/x/y/z" "$ctr_src_opts"
config_add_bind_mount "$rootfs/mnt/x" "/mnt/x/y/z/x" "$ctr_src_opts"
config_add_bind_mount "$rootfs/mnt/x/y" "/mnt/x/y/z" "$ctr_src_opts"
# Finally, bind-mount the whole thing on top of /final.
config_add_bind_mount "$rootfs/mnt" "$rootfs/final" "$ctr_src_opts"
config_add_bind_mount "$rootfs/mnt" "/final" "$ctr_src_opts"

# Check that the entire tree was copied and the mounts were done in the
# expected order.
Expand Down