Skip to content

Conversation

@ca-hu
Copy link
Contributor

@ca-hu ca-hu commented Nov 25, 2025

account-utils needs to write /proc/<pid_of_containers>/uid_map and gid_map.

We are currently working to confining three systemd services of account-utils in the openSUSE
policy (downstream of fedora policy) and this needs an interface from the container-selinux side.

Context:

Summary by Sourcery

New Features:

  • Introduce a container_write_proc_files interface for writing uid_map and gid_map under /proc of container processes from account-utils-related services.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 25, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduce a new SELinux interface to allow confined services (like account-utils) to write container /proc uid_map and gid_map files via the container-selinux policy.

File-Level Changes

Change Details Files
Add a new SELinux interface to permit writing container /proc uid_map and gid_map files.
  • Define the container_write_proc_files interface with appropriate SELinux permissions to write uid_map and gid_map under /proc for container processes
  • Wire the new interface into the container policy so confined services can use it to manage container UID/GID mappings
container.if

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link

Summary of Changes

Hello @ca-hu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new SELinux interface, container_write_proc_files, designed to grant necessary write permissions to /proc files within container runtimes. This is a targeted enhancement to support the account-utils project's ability to manage UID and GID mappings for containers, thereby enabling the proper confinement of its systemd services under the openSUSE policy.

Highlights

  • New SELinux Interface: Introduced a new SELinux interface named container_write_proc_files to manage permissions for container processes.
  • Purpose of Interface: This interface allows a specified domain to write to /proc/<PID>/uid_map and gid_map files within a container runtime, which is crucial for setting user and group ID mappings.
  • Addressing account-utils Needs: The change directly supports the account-utils project, specifically its newidmapd.c component, which requires these write permissions for proper container confinement in openSUSE policy.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new SELinux interface, container_write_proc_files, to allow confined services to write to /proc/<pid>/uid_map and gid_map for container processes. While the new interface is useful, the permissions granted are overly broad, which could introduce security risks. I've suggested restricting the permissions to only what is necessary for the intended operation.

container.if Outdated
type container_runtime_t;
')

allow $1 container_runtime_t:file write_file_perms;

Choose a reason for hiding this comment

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

high

The write_file_perms macro is overly permissive for the intended purpose of writing to uid_map and gid_map. It grants permissions like create, unlink, and rename, which could lead to unintended and potentially insecure operations on the /proc filesystem for the container runtime process. The linked account-utils code only requires open and write permissions. To follow the principle of least privilege, it's better to grant only the necessary permissions.

allow $1 container_runtime_t:file { open write };

@ca-hu ca-hu marked this pull request as draft November 25, 2025 15:36
@ca-hu ca-hu force-pushed the account-utils-set-uidmap branch from 9c06175 to 4d92724 Compare November 25, 2025 15:39
@packit-as-a-service
Copy link

Tests failed. @containers/packit-build please check.

@ca-hu ca-hu marked this pull request as ready for review November 25, 2025 16:07
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

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

@ca-hu thanks for the PR. Change LGTM, but needs DCO, could you please signoff on the commit?

@rhatdan @haircommander PTAL.

type container_runtime_t;
')

allow $1 container_runtime_t:file { open write };
Copy link
Collaborator

Choose a reason for hiding this comment

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

the description seems to imply that this account-utils needs to run inside the container, but I'd xpect container_runtime_t to be used by an oci runtime tosetup for the container. can you explain the case a bit more to make sure we're targeting the right type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, account-utils runs outside of the containers on the host and newidmapd is used to write to the /proc/<pid_of_container_runtime>/uid_map of the container runtime on the host for UID mapping between host and containers. and the /proc of the container runtime is labelled as container_runtime_t

see: https://www.thkukuk.de/blog/no_new_privs/

account-utils needs to write /proc/<pid_of_containers>/uid_map
and gid_map

https://github.com/thkukuk/account-utils/blob/bf57c14f254570b4e5ad24925d8e481bff2ab828/src/newidmapd.c#L216

Signed-off-by: Cathy Hu <cathy.hu@suse.com>
@ca-hu ca-hu force-pushed the account-utils-set-uidmap branch from 4d92724 to c6349ab Compare November 26, 2025 08:23
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

2 similar comments
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@lsm5
Copy link
Member

lsm5 commented Nov 26, 2025

/packit build
/packit test

@packit-as-a-service
Copy link

Tests failed. @containers/packit-build please check.

@haircommander
Copy link
Collaborator

LGTM @lsm5 are you worried about the fedora failures?

@lsm5
Copy link
Member

lsm5 commented Nov 26, 2025

LGTM @lsm5 are you worried about the fedora failures?

looks like the ELN image changed the rootless user. Can be fixed elsewhere.

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Nov 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ca-hu, lsm5, sourcery-ai[bot]

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lsm5
Copy link
Member

lsm5 commented Nov 26, 2025

wonder if something's wrong with mergebot. Alternatively, might be good to follow whatever podman's gonna do for mergebot replacement.

@lsm5
Copy link
Member

lsm5 commented Nov 26, 2025

@ca-hu would you like a new release cut right away?

@openshift-merge-bot openshift-merge-bot bot merged commit d72cbcb into containers:main Nov 26, 2025
29 of 31 checks passed
@ca-hu
Copy link
Contributor Author

ca-hu commented Nov 26, 2025

@ca-hu would you like a new release cut right away?

sure if that is fine with you, thanks!

@lsm5
Copy link
Member

lsm5 commented Nov 26, 2025

/cherrypick rhaos-maint

@openshift-cherrypick-robot

@lsm5: new pull request created: #418

In response to this:

/cherrypick rhaos-maint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants