Skip to content

Conversation

debarshiray
Copy link
Member

@debarshiray debarshiray commented Mar 8, 2025

Toolbx containers are super privileged containers [1,2], because they use the host's cgroup, IPC, network and PID namespaces, and turn off SELinux label separation. It's likely that users will want to use PipeWire inside Toolbx containers because they need some form of audio or video, and PipeWire needs to be able to use RealtimeKit to change the CPU priority of processes using these D-Bus interfaces:

  • org.freedesktop.RealtimeKit1.MakeThreadHighPriorityWithPID
  • org.freedesktop.RealtimeKit1.MakeThreadRealtimeWithPID

If the SELinux policy blocks the processes inside super privileged containers from using RealtimeKit, then it will lead to:

  type=AVC msg=audit(1721340769.363:269): avc:  denied  { setsched } for
      pid=762 comm="rtkit-daemon"
      scontext=system_u:system_r:rtkit_daemon_t:s0
      tcontext=unconfined_u:unconfined_r:spc_t:s0 tclass=process
      permissive=0

[1] https://developers.redhat.com/blog/2014/11/06/introducing-a-super-privileged-container-concept

[2] https://danwalsh.livejournal.com/74754.html

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2298800

Summary by Sourcery

Bug Fixes:

  • Fixes an issue where SELinux policy blocks processes inside super privileged containers from using RealtimeKit.

Toolbx containers are super privileged containers [1,2], because they
use the host's cgroup, IPC, network and PID namespaces, and turn off
SELinux label separation.  It's likely that users will want to use
PipeWire inside Toolbx containers because they need some form of audio
or video, and PipeWire needs to be able to use RealtimeKit to change the
CPU priority of processes using these D-Bus interfaces:
  * org.freedesktop.RealtimeKit1.MakeThreadHighPriorityWithPID
  * org.freedesktop.RealtimeKit1.MakeThreadRealtimeWithPID

If the SELinux policy blocks the processes inside super privileged
containers from using RealtimeKit, then it will lead to:
  type=AVC msg=audit(1721340769.363:269): avc:  denied  { setsched } for
      pid=762 comm="rtkit-daemon"
      scontext=system_u:system_r:rtkit_daemon_t:s0
      tcontext=unconfined_u:unconfined_r:spc_t:s0 tclass=process
      permissive=0

[1] https://developers.redhat.com/blog/2014/11/06/introducing-a-super-privileged-container-concept

[2] https://danwalsh.livejournal.com/74754.html

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2298800

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
Copy link

sourcery-ai bot commented Mar 8, 2025

Reviewer's Guide by Sourcery

This pull request modifies the SELinux policy to allow processes within super privileged containers (specifically those labeled with spc_t) to utilize RealtimeKit for adjusting process scheduling priorities. This is achieved by granting the rtkit_daemon_t domain the necessary permissions to set scheduling parameters for processes running in the spc_t domain.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Allow processes running in super privileged containers to use RealtimeKit for scheduling.
  • Added a rule to allow the rtkit_daemon_t domain to set scheduling parameters for processes in the spc_t domain.
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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

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 @debarshiray - I've reviewed your changes - here's some feedback:

Overall Comments:

  • It would be helpful to add a comment to the code explaining why this change is necessary.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@debarshiray
Copy link
Member Author

My SELinux knowledge is limited, and this is completely untested. However, there's extensive debugging information in the original bug, and I followed the suggestions from @rhatdan and @zpytela

@rhatdan
Copy link
Member

rhatdan commented Mar 9, 2025

/approve
/lgtm

Copy link

openshift-ci bot commented Mar 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: debarshiray, rhatdan

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

@openshift-ci openshift-ci bot added the approved label Mar 9, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 2c6d8b8 into containers:main Mar 9, 2025
29 checks passed
@debarshiray
Copy link
Member Author

Thanks for the review, @rhatdan !

@lsm5
Copy link
Member

lsm5 commented Mar 10, 2025

@debarshiray is it possible to include a bats test for this case, maybe in the toolbox repo such that we could run it here on container-selinux CI?

@debarshiray
Copy link
Member Author

@debarshiray is it possible to include a bats test for this case, maybe in the toolbox repo such that we could run it here on container-selinux CI?

Yes, it should be possible. I will add one. I need to figure out the best way to check for the SELinux denials from the tests.

@lsm5
Copy link
Member

lsm5 commented Apr 23, 2025

/cherrpick rhaos-maint

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.

3 participants