Skip to content

Conversation

ToolmanP
Copy link

@ToolmanP ToolmanP commented Feb 18, 2025

When only the user namespace is isolated in the given task, cr-restore will fail to mount the procfs in the new user namespace because of the loss of privileges.

Delegate usernsd to do the mount job if that corner case arises.

Fixes: #2597

int fd, ret;

if ((root_ns_mask & CLONE_NEWUSER) && !(root_ns_mask & CLONE_NEWNS))
fd = ret = userns_call(userns_mount_proc, UNS_FDOUT, NULL, sizeof(NULL), -1);
Copy link
Member

Choose a reason for hiding this comment

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

will it be mounted in the target pid namespace?

Copy link
Author

@ToolmanP ToolmanP Feb 24, 2025

Choose a reason for hiding this comment

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

No i don't think it will be mounted and it's gonna be rejected. I fixed this now. The corner case is only when the user namespace is isolated while keeping both mount namespace and pid namespace be shared with host. If either of two namespaces are isolated, the proc fs will be mounted successfully.

Copy link
Member

Choose a reason for hiding this comment

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

If a target workload is restored in just separate userns and pid namespaces, userns_mount_proc will fail, because the current process doesn't have CAP_SYS_ADMIN in the current mount namespace. The only way to workaround that is to mount proc from usernsd, and the userns mount callback has to enter the target pid namespace before mounting proc.

@ToolmanP ToolmanP force-pushed the fix-mount-proc branch 2 times, most recently from 43dbd40 to eda5ab0 Compare March 4, 2025 17:42
@ToolmanP
Copy link
Author

ToolmanP commented Mar 4, 2025

Rebased to criu-dev

When the user namespace is separate from both pid and mount namespace
in the given task, cr-restore will fail to mount the procfs
in the new user namespace because of the loss of privileges.

Delegate usernsd to do the mount job if that corner case arises.

Signed-off-by: Yiyang Wu <[email protected]>
Copy link

github-actions bot commented Apr 4, 2025

A friendly reminder that this PR had no activity for 30 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to restore a small code in user namespace

2 participants