linux: open bind mount sources inside the rootfs at mount time - #2306
Merged
Merged
Conversation
A bind mount source inside the container rootfs refers to what is there at the time of the mount, including the mounts done before it. Yet such sources were opened beforehand, along with all the other bind mount sources (by the host with a user namespace, or before the first mount otherwise), so they referred to the rootfs as it was before any mounts. Do not open such sources beforehand. Instead, open them relative to the container rootfs when doing the mount. This does not work for idmapped mounts, which can only be created by the host. Add a test case. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
marked this pull request as ready for review
October 1, 2026 04:56
giuseppe
approved these changes
Oct 1, 2026
giuseppe
left a comment
Member
There was a problem hiding this comment.
ah, I know about this difference with runc and hoped nobody noticed :-)
LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A bind mount source inside the container rootfs refers to what is there at the time of the mount, including the mounts done before it. Such sources were opened beforehand along with other bind mount sources (by the host with a user namespace, or before the first mount otherwise), so they referred to the rootfs as it was before any mounts.
Do not open such sources beforehand; open them relative to the container rootfs when doing the mount. This does not cover idmapped mounts, which can only be created by the host.
Adds a test case. The corresponding runc tests (
mounts.bats: runc run [mount order, container bind-mount source]with and without userns) can be enabled once opencontainers/runc#5503 is merged, as they currently use host rootfs paths as mount destinations.