Skip to content

runsc: support unprivileged user namespace mappings using SysProcAttr#12812

Open
copybara-service[bot] wants to merge 1 commit intomasterfrom
test/cl891146229
Open

runsc: support unprivileged user namespace mappings using SysProcAttr#12812
copybara-service[bot] wants to merge 1 commit intomasterfrom
test/cl891146229

Conversation

@copybara-service
Copy link
Copy Markdown

runsc: support unprivileged user namespace mappings using SysProcAttr

When running in rootless mode, runsc currently relies on newuidmap and
newgidmap to set up user namespace mappings. However, these binaries are
setuid and might be unavailable or disabled in certain environments, such
as nested unprivileged containers.

If the requested mappings are simple (exactly one mapping of size 1 that
maps to the current effective UID/GID), the Linux kernel allows an
unprivileged process to set its own mappings. Go's os/exec package
supports this via SysProcAttr.UidMappings and SysProcAttr.GidMappings.

This change adds a CanUseUnprivilegedMapping helper to check if the
requested mappings are compatible with this unprivileged approach. If
they are, createSandboxProcess and createGoferProcess will configure
cmd.SysProcAttr directly, bypassing the need for newuidmap/newgidmap.

For more complex mappings, runsc continues to fall back to the existing
newuidmap/newgidmap mechanism.

When running in rootless mode, runsc currently relies on newuidmap and
newgidmap to set up user namespace mappings. However, these binaries are
setuid and might be unavailable or disabled in certain environments, such
as nested unprivileged containers.

If the requested mappings are simple (exactly one mapping of size 1 that
maps to the current effective UID/GID), the Linux kernel allows an
unprivileged process to set its own mappings. Go's os/exec package
supports this via SysProcAttr.UidMappings and SysProcAttr.GidMappings.

This change adds a CanUseUnprivilegedMapping helper to check if the
requested mappings are compatible with this unprivileged approach. If
they are, createSandboxProcess and createGoferProcess will configure
cmd.SysProcAttr directly, bypassing the need for newuidmap/newgidmap.

For more complex mappings, runsc continues to fall back to the existing
newuidmap/newgidmap mechanism.

PiperOrigin-RevId: 891146229
@copybara-service copybara-service bot added the exported Issue was exported automatically label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant