Skip to content

libct: fix rootfs mount leak with --no-pivot and shared root - #5532

Open
kolyshkin wants to merge 1 commit into
opencontainers:mainfrom
kolyshkin:no-pivot-shared
Open

kolyshkin wants to merge 1 commit into
opencontainers:mainfrom
kolyshkin:no-pivot-shared

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

When --no-pivot is used, runc moves the container rootfs on top of / (using MS_MOVE). If the root mount is shared (e.g. when rootfsPropagation is set to rshared) and the container rootfs is a mount (e.g. overlay), the move is propagated to the host, resulting in the container rootfs being mounted on top of the host's /. This breaks the host, e.g. subsequent containers fail to start.

To fix, make / a slave before the move.

Add an integration test (marked as unsafe, since without the fix it breaks the host).

Fixes #1961.

@kolyshkin

Copy link
Copy Markdown
Contributor Author

In view of #4434 we may drop this PR (together with --no-pivot), OTOH the fix itself is quite simple.

@kolyshkin
kolyshkin marked this pull request as ready for review October 13, 2026 00:37
@kolyshkin

Copy link
Copy Markdown
Contributor Author

Not sure why it was draft -- it's not.

When --no-pivot is used, runc moves the container rootfs on top of
"/" (using MS_MOVE). If the root mount is shared (e.g. when
rootfsPropagation is set to "rshared") and the container rootfs is a
mount (e.g. overlay), the move is propagated to the host, resulting in
the container rootfs being mounted on top of the host's "/". This
breaks the host, e.g. subsequent containers fail to start.

To fix, make "/" a slave before the move.

Add an integration test.

Fixes opencontainers#1961.

Assisted-by: Claude Opus 5.5
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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.

Launching container with shared volume on rootfs changes root filesystem to overlay and can't launch containers

1 participant