Skip to content

restore: fix bind mounts with a relative source, nested bind mounts - #2240

Merged
kolyshkin merged 2 commits into
containers:mainfrom
kolyshkin:cr-restore-relative-bind
Sep 11, 2026
Merged

kolyshkin merged 2 commits into
containers:mainfrom
kolyshkin:cr-restore-relative-bind

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator
  1. restore: fix bind mounts with a relative source

    A relative bind mount source is relative to the bundle, but it is passed to CRIU as is, and so CRIU resolves it relative to its own working directory, failing with something like:

    Error (criu/mount-v2.c:319): mnt-v2: Failed to open_tree ./tmp.opElJ45fj6: No such file or directory
    

    Make the source absolute before passing it to CRIU.

  2. restore: create mountpoints inside bind mount sources

    Before restore, crun recreates the mountpoints which do not exist in the container rootfs, as it is done on the container creation. Yet, unlike the container creation, the bind mounts are not mounted at this time, so the mountpoint of a mount which is inside a bind mount (e.g. a nested bind mount) is created in the rootfs underneath the bind mount, rather than in the bind mount source. As a result, if the mountpoint does not exist in the source, restore fails with something like:

    Error (criu/mount-v2.c:634): mnt-v2: Can't stat mountpoint /tmp/.criu.mntns.bAeDM2/mnt-0000000147/for/nested: No such file or directory
    

    Do what runc does: temporarily mount the bind mounts while creating the mountpoints, and unmount them afterwards, as CRIU restores the mounts itself.

    Unlike runc, do not use recursive bind mounts: the source might contain the restore root itself (e.g. when it is the bundle directory, as crun mounts the rootfs under the bundle for CRIU), resulting in a mess which brings down the restore root when unmounted.

Found by the "checkpoint and restore with nested bind mounts" runc integration test (see #2238).

@kolyshkin kolyshkin changed the title restore: fix bind mounts with a relative source restore: fix bind mounts with a relative source, nested bind mounts Sep 11, 2026
@kolyshkin
kolyshkin force-pushed the cr-restore-relative-bind branch from c6e1a1b to dcef41d Compare September 11, 2026 01:46

@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.

LGTM

@giuseppe

Copy link
Copy Markdown
Member

there is a conflict

A relative bind mount source is relative to the bundle, but it is passed
to CRIU as is, and so CRIU resolves it relative to its own working
directory, failing with something like:

  Error (criu/mount-v2.c:319): mnt-v2: Failed to open_tree ./tmp.opElJ45fj6: No such file or directory

Make the source absolute before passing it to CRIU.

Found by the "checkpoint and restore with nested bind mounts" runc
integration test.

Signed-off-by: Kir Kolyshkin <[email protected]>
Before restore, crun recreates the mountpoints which do not exist in the
container rootfs, as it is done on the container creation. Yet, unlike
the container creation, the bind mounts are not mounted at this time, so
the mountpoint of a mount which is inside a bind mount (e.g. a nested
bind mount) is created in the rootfs underneath the bind mount, rather
than in the bind mount source. As a result, if the mountpoint does not
exist in the source, restore fails with something like:

  Error (criu/mount-v2.c:634): mnt-v2: Can't stat mountpoint /tmp/.criu.mntns.bAeDM2/mnt-0000000147/for/nested: No such file or directory

Do what runc does: temporarily mount the bind mounts while creating the
mountpoints, and unmount them afterwards, as CRIU restores the mounts
itself.

Unlike runc, do not use recursive bind mounts: the source might contain
the restore root itself (e.g. when it is the bundle directory, as crun
mounts the rootfs under the bundle for CRIU), resulting in a mess which
brings down the restore root when unmounted.

Found by the "checkpoint and restore with nested bind mounts" runc
integration test.

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
kolyshkin force-pushed the cr-restore-relative-bind branch from dcef41d to b5c8fdf Compare September 11, 2026 16:13
@kolyshkin
kolyshkin merged commit 6df9af7 into containers:main Sep 11, 2026
59 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