libct: fail if additional gids cannot be set by kolyshkin · Pull Request #5545 · opencontainers/runc · GitHub
Skip to content

libct: fail if additional gids cannot be set - #5545

Open
kolyshkin wants to merge 1 commit into
opencontainers:mainfrom
kolyshkin:setgroups-deny-gids
Open

kolyshkin wants to merge 1 commit into
opencontainers:mainfrom
kolyshkin:setgroups-deny-gids

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

When setgroups(2) is denied in the container user namespace (e.g. when runc
is run inside unshare -r, or the container joins such a user namespace), runc
silently skipped setting the supplementary groups, so a container (or exec)
explicitly configured with additional gids started successfully without them.

Return an error instead. An additional gid equal to the process gid is
tolerated, since it is in effect anyway; this is what Podman passes when running
with a single ID mapping (it always adds the user's primary gid), so that setup
keeps working.

The rootless EUID case is already rejected earlier, in (*Container).start.

The new integration test creates an external user namespace with setgroups
denied, joins it, and checks both runc run and runc exec. It is written to
also pass with crun (with containers/crun#2321).

Originally reported for crun in containers/crun#2320; crun counterpart is
containers/crun#2321.

@kolyshkin

Copy link
Copy Markdown
Contributor Author

When setgroups(2) is denied in the container user namespace (e.g. when
runc is run inside "unshare -r", or the container joins such a user
namespace), runc silently skipped setting the supplementary groups,
so a container (or exec) explicitly configured with additional gids
started successfully without them.

Return an error instead. An additional gid equal to the process gid is
tolerated, as it is in effect anyway; this is what Podman passes when
running with a single ID mapping.

The old comment about not being explicitly asked to set the groups is
no longer true, since additional groups only come from the spec.

The rootless EUID case is already rejected earlier, in (*Container).start.

Reported-in: containers/crun#2320

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
kolyshkin force-pushed the setgroups-deny-gids branch from c171362 to c2763ab Compare October 19, 2026 06:04
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.

1 participant