Skip to content

Support running with no_new_privs - #656

Open
ricardobranco777 wants to merge 2 commits into
rootless-containers:masterfrom
ricardobranco777:fix-no-new-privs
Open

ricardobranco777 wants to merge 2 commits into
rootless-containers:masterfrom
ricardobranco777:fix-no-new-privs

Conversation

@ricardobranco777

Copy link
Copy Markdown

The child was started with CLONE_NEWUSER before its uid_map was written, so the exec dropped all the caps, and the child re-executed itself after the maps were written to gain them. With no_new_privs set, the re-exec cannot gain caps, so the child ended up waiting forever for a message from the parent.

Start the child with all the caps as ambient caps, so it keeps them across the exec and does not need to re-execute. The re-execution is kept as a fallback. The child now always does the handshake with the parent once, and clears the inheritable and ambient caps afterwards so they are not inherited by the workload.

Fixes #551

@ricardobranco777

ricardobranco777 commented Oct 20, 2026 •

Copy link
Copy Markdown
Author

Steps to test on openSUSE Tumbleweed 20261018:

zypper in enable-no_new_privs
systemctl enable --now polkit-agent-helper.socket
reboot

rootlesskit true now works and I can run rootless Docker.

@AkihiroSuda
AkihiroSuda requested a balanced review from Copilot October 23, 2026 15:04
@AkihiroSuda AkihiroSuda added this to the v3.4.0 milestone Oct 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unconditional ambient-capability operations prevent startup on kernels without that support, bypassing the retained fallback.

1 open issue
What changed in this PR

This PR addresses the startup hang under no_new_privs described in #551 by preserving the child’s capabilities across execution.

Changes:

  • Pass ambient capabilities to the child while retaining the re-execution fallback.
  • Perform the parent-child handshake once and clear inheritable and ambient capabilities before starting the workload.
  • Add regression coverage for both PID namespace modes and run it in CI.
File Description
pkg/​parent/​parent.go Populate the child’s ambient capabilities from kernel-supported capabilities.
pkg/​child/​child.go Update handshake and re-execution handling; clear inherited capabilities.
hack/​integration-no-new-privs.sh Test startup under no_new_privs with and without a PID namespace.
.github/​workflows/​main.yaml Run the new integration test in CI.

Review effort: Balanced

Comment thread pkg/parent/parent.go
Comment thread pkg/child/child.go Outdated
Comment thread pkg/child/child.go Outdated
ricardobranco777 and others added 2 commits October 23, 2026 17:48
The child was started with CLONE_NEWUSER before its uid_map was written,
so the exec dropped all the caps, and the child re-executed itself after
the maps were written to gain them. With no_new_privs set, the re-exec
cannot gain caps, so the child ended up waiting forever for a message
from the parent.

Start the child with all the caps as ambient caps, so it keeps them
across the exec and does not need to re-execute. The re-execution is
kept as a fallback for kernels without ambient caps (older than 4.3).
The child now always does the handshake with the parent once, and clears
the inheritable and ambient caps afterwards so they are not inherited by
the workload.

Fixes rootless-containers#551

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Run rootlesskit under `setpriv --no-new-privs` with unprivileged
newuidmap/newgidmap stand-ins (the real ones are setuid or have file caps,
which no_new_privs disables), and check that the child gets the caps and
that no ambient caps leak into the workload.

Without the fix for rootless-containers#551, rootlesskit hangs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Ricardo Branco <rbranco@suse.de>
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.

rootlesskit hangs in a session with no_new_privs set

3 participants