Skip to content

criu: handle the devices of a container with a user namespace - #2465

Merged
giuseppe merged 2 commits into
containers:mainfrom
kolyshkin:criu-userns-devices
Nov 11, 2026
Merged

giuseppe merged 2 commits into
containers:mainfrom
kolyshkin:criu-userns-devices

Conversation

@kolyshkin

Copy link
Copy Markdown
Collaborator

This is an alternative to #2463, using a different approach:

  • tell CRIU about the devices bind mounts explicitly;
  • on restore, creates the devices from linux.devices again on a tmpfs
    (sharing the code with create) and gives them to CRIU as the sources;
  • enforces nosuid,noexec on the restored device mounts, like on the
    other external mounts;
  • fixes a create bug found on the way: with a user namespace, a default
    device (e.g. /dev/null) bind mounted from the host was hiding a device
    with the same path from linux.devices, ignoring its owner and mode.

The has_user_namespace helper and the checkpoint-restore-userns test
are taken from #2463.

Not covered: a container with a user namespace but without a network
namespace bind mounts the host /sys, and its checkpoint still fails
(with either approach) on the submounts like selinuxfs.

With a user namespace the default devices are bind mounted from the
host, also over a device with the same path in the configuration,
hiding it.  Without a user namespace the existing device is kept
instead.  Skip the default devices that are in the configuration.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
A container with a user namespace cannot create device nodes, so they
are bind mounted: the devices in the configuration from a tmpfs where
crun creates them, the default devices from the host.  CRIU was only
told about the bind mounts listed in the configuration, so the
checkpoint failed with:

  mnt: ./dev/urandom doesn't have a proper root mount

Tell CRIU about the devices bind mounts explicitly, as runc does.  On
restore, create the devices in the configuration again on a tmpfs and
give them to CRIU as the sources of their mounts, and restore the
nosuid,noexec flags on all of them.

Add checkpoint/restore tests with a user namespace, with and without
devices in the configuration.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@packit-as-a-service

Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

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

this is better, thanks!

LGTM

@giuseppe
giuseppe added this pull request to the merge queue Nov 11, 2026
Merged via the queue into containers:main with commit e7e1012 Nov 11, 2026
71 of 73 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