You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
idmap/ridmap mounts are validated to be bind mounts and require both uid/gid mappings.
During rootfs setup, Init requests an idmapped mount fd from Main via the channel.
Main creates a short‑lived UserNS helper, writes uid/gid maps (and setgroups=deny if needed), opens the UserNS fd, then runs open_tree + mount_setattr to create an idmapped mount fd.
The mount fd is sent back to Init, which performs move_mount to the destination and applies any remount/recursive attributes.
userns_fd can be dropped after mount_setattr; the idmapped mount remains valid.
Sequence Diagram
sequenceDiagram
participant Init as "Youki (Init Process)"
participant Main as "Youki (Main Process)"
participant Helper as "UserNS helper (CLONE_NEWUSER)"
Init->>Init: validate spec (idmap/ridmap requires bind + uid/gid mappings)
Main->>Main: wait for MountFdPlease
Init->>Main: MountFdPlease(MountMsg{source,idmap,recursive})
Main->>Helper: fork()
activate Helper
Helper->>Helper: unshare(CLONE_NEWUSER)
Helper->>Helper: wait for pipe (keeps userns alive)
Main->>Main: write /proc/<pid>/uid_map, gid_map
Main->>Main: open /proc/<pid>/ns/user (userns_fd)
Main->>Main: open_tree(source, flags)
Main->>Main: mount_setattr(MOUNT_ATTR_IDMAP, userns_fd)
Main->>Main: drop userns_fd (UserNS closes)
Main-->>Init: MountFdReply (mount_fd)
Init->>Init: move_mount(mount_fd, dest)
Activity
utam0k commentedon Jan 18, 2024
@lengrongfu Do you have an interest in this issue? This is not simple, but it would be good to learn container runtime.
lengrongfu commentedon Jan 18, 2024
Thanks, i can.
lengrongfu commentedon Jan 18, 2024
/assign
utam0k commentedon Jan 26, 2024
@lengrongfu Thanks. I'm looking forward to seeing your PR. It will be a wonderful feature.
YamasouA commentedon Sep 22, 2025
Hey @lengrongfu
I’m also interested in this issue. Are you still working on it?
If not, I’d be happy to pick it up and continue.
YamasouA commentedon Feb 28, 2026
Summary:
Sequence Diagram
sequenceDiagram participant Init as "Youki (Init Process)" participant Main as "Youki (Main Process)" participant Helper as "UserNS helper (CLONE_NEWUSER)" Init->>Init: validate spec (idmap/ridmap requires bind + uid/gid mappings) Main->>Main: wait for MountFdPlease Init->>Main: MountFdPlease(MountMsg{source,idmap,recursive}) Main->>Helper: fork() activate Helper Helper->>Helper: unshare(CLONE_NEWUSER) Helper->>Helper: wait for pipe (keeps userns alive) Main->>Main: write /proc/<pid>/uid_map, gid_map Main->>Main: open /proc/<pid>/ns/user (userns_fd) Main->>Main: open_tree(source, flags) Main->>Main: mount_setattr(MOUNT_ATTR_IDMAP, userns_fd) Main->>Main: drop userns_fd (UserNS closes) Main-->>Init: MountFdReply (mount_fd) Init->>Init: move_mount(mount_fd, dest)