Skip to content

linux: open bind mount sources inside the rootfs at mount time - #2306

Merged
giuseppe merged 1 commit into
containers:mainfrom
kolyshkin:mount-src-in-rootfs
Oct 1, 2026
Merged

giuseppe merged 1 commit into
containers:mainfrom
kolyshkin:mount-src-in-rootfs

Conversation

@kolyshkin

Copy link
Copy Markdown
Collaborator

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.

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
kolyshkin marked this pull request as ready for review October 1, 2026 04:56

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah, I know about this difference with runc and hoped nobody noticed :-)

LGTM

@giuseppe
giuseppe merged commit 8d439fb into containers:main Oct 1, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants