Skip to content

[RHEL 8] Allow user_t and container_runtime_t to exchange dbus messages#448

Open
lsm5 wants to merge 1 commit intocontainers:mainfrom
lsm5:rhel8-dbus
Open

[RHEL 8] Allow user_t and container_runtime_t to exchange dbus messages#448
lsm5 wants to merge 1 commit intocontainers:mainfrom
lsm5:rhel8-dbus

Conversation

@lsm5
Copy link
Copy Markdown
Member

@lsm5 lsm5 commented Mar 17, 2026

When user_t runs rootless podman (which transitions to container_runtime_t), podman communicates with the systemd user session (user_t) via D-Bus to manage cgroups by calling StartTransientUnit.

Without this rule, systemd processes the request but SELinux blocks the D-Bus reply from user_t back to container_runtime_t. Podman then hangs indefinitely waiting for a response that never arrives. This denial doesn't show in the audit log as AVC because D-Bus access denials are handled by dbus-daemon itself, only visible via dbus-monitor as org.freedesktop.DBus.Error.AccessDenied:

error_name=org.freedesktop.DBus.Error.AccessDenied
"An SELinux policy prevents this sender from sending this message
to this recipient, 0 matched rules; type="method_return",
sender=":1.1" (uid=1001 pid=9877 comm="/usr/lib/systemd/systemd
--user " label="user_u:user_r:user_t:s0") interface="(unset)"
member="(unset)" error name="(unset)" requested_reply="0"
destination=":1.4" (uid=1001 pid=9917 comm="podman images "
label="user_u:user_r:container_runtime_t:s0")"

Add dbus send_msg rules between user_t and container_runtime_t inside the user_t_run_containers tunable to allow this communication.

This fix is specific to RHEL8 which uses dbus-daemon that enforces SELinux send_msg checks between peers. RHEL9+ and Fedora use dbus-broker which does not enforce peer-to-peer send_msg checks, so this rule is not needed there but is harmless.

Summary by Sourcery

Bug Fixes:

  • Resolve a hang in rootless Podman on RHEL 8 by allowing D-Bus replies between user_t and container_runtime_t under the user_t_run_containers tunable.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 17, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates SELinux policy for containers on RHEL 8 so that, when the user_t_run_containers tunable is enabled, user_t and container_runtime_t domains are allowed to exchange D-Bus messages, preventing rootless Podman/systemd user-session hangs caused by blocked D-Bus replies.

File-Level Changes

Change Details Files
Allow peer D-Bus messaging between user_t and container_runtime_t when user_t_run_containers is enabled, specifically for RHEL 8 dbus-daemon behavior.
  • Add allow rules for user_t to send D-Bus messages to container_runtime_t via dbus-daemon, conditional on the user_t_run_containers tunable.
  • Add reciprocal allow rules for container_runtime_t to send D-Bus messages back to user_t via dbus-daemon, under the same tunable.
  • Scope the new policy to accommodate RHEL 8’s dbus-daemon SELinux send_msg enforcement while remaining harmless on RHEL 9+ and Fedora.
container.te

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
Copy Markdown

Summary of Changes

Hello, 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 addresses a critical SELinux policy gap in RHEL 8 that caused rootless Podman to hang during D-Bus communication with the systemd user session. By introducing specific D-Bus send_msg permissions, the change ensures proper interaction between user processes and container runtimes, thereby unblocking container operations that rely on D-Bus for cgroup management.

Highlights

  • SELinux D-Bus Policy Update: Added two new SELinux rules to permit bidirectional D-Bus message exchange between the user_t and container_runtime_t contexts. These rules are nested within the user_t_run_containers tunable.
  • Rootless Podman Fix for RHEL 8: Resolved an issue specific to RHEL 8 where rootless Podman would hang indefinitely due to SELinux blocking D-Bus replies from user_t (systemd user session) back to container_runtime_t when managing cgroups.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • container.te
    • Added allow user_t container_runtime_t:dbus send_msg; to permit D-Bus messages from user processes to container runtimes.
    • Added allow container_runtime_t user_t:dbus send_msg; to permit D-Bus messages from container runtimes back to user processes.
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
Copy Markdown

@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 adds SELinux rules to permit bidirectional D-Bus communication between the user_t and container_runtime_t contexts. This change is necessary on RHEL 8 to allow rootless Podman, running as container_runtime_t, to communicate with the systemd user session, running as user_t, for cgroup management. Without these rules, Podman hangs while waiting for a D-Bus reply that is blocked by SELinux. The new rules are correctly placed within the user_t_run_containers tunable, which is disabled by default, ensuring the change is opt-in for administrators. The change is correct and effectively resolves the issue.

@lsm5 lsm5 marked this pull request as ready for review March 18, 2026 11:59
Copy link
Copy Markdown

@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 - 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.

@lsm5
Copy link
Copy Markdown
Member Author

lsm5 commented Mar 18, 2026

@containers/container-selinux-maintainers PTAL. Required only by rhel8 but shouldn't hurt to be on main. Just that having this present upstream makes it easy to point to.

When user_t runs rootless podman (which transitions to
container_runtime_t), podman communicates with the systemd user session
(user_t) via D-Bus to manage cgroups by calling StartTransientUnit.

Without this rule, systemd processes the request but SELinux blocks the
D-Bus reply from user_t back to container_runtime_t. Podman then hangs
indefinitely waiting for a response that never arrives. This denial
doesn't show in the audit log as AVC because D-Bus access denials are
handled by dbus-daemon itself, only visible via dbus-monitor as
org.freedesktop.DBus.Error.AccessDenied:

```
error_name=org.freedesktop.DBus.Error.AccessDenied
"An SELinux policy prevents this sender from sending this message
to this recipient, 0 matched rules; type="method_return",
sender=":1.1" (uid=1001 pid=9877 comm="/usr/lib/systemd/systemd
--user " label="user_u:user_r:user_t:s0") interface="(unset)"
member="(unset)" error name="(unset)" requested_reply="0"
destination=":1.4" (uid=1001 pid=9917 comm="podman images "
label="user_u:user_r:container_runtime_t:s0")"
```

Add dbus send_msg rules between user_t and container_runtime_t inside
the user_t_run_containers tunable to allow this communication.

This fix is specific to RHEL8 which uses `dbus-daemon`
that enforces SELinux send_msg checks between peers.
RHEL9+ and Fedora use `dbus-broker` which does not enforce peer-to-peer
send_msg checks, so this rule is not needed there but is harmless.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
@packit-as-a-service
Copy link
Copy Markdown

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

@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented Mar 26, 2026

Does Podman work on RHEL8? Or is this a badly named branch.

LGTM

@lsm5
Copy link
Copy Markdown
Member Author

lsm5 commented Mar 26, 2026

Does Podman work on RHEL8? Or is this a badly named branch.

It does, well whatever version is already shipped on RHEL 8.10. And only RHEL8 needs this additional patch.

LGTM

Thanks.

@lsm5
Copy link
Copy Markdown
Member Author

lsm5 commented Mar 26, 2026

/packit retest-failed

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.

2 participants