Skip to content

Conversation

sohankunkerkar
Copy link
Member

@sohankunkerkar sohankunkerkar commented Aug 30, 2025

Problem: crun PR #1859 (containers/crun#1859) optimizes masked paths by using a shared empty directory instead of individual tmpfs mounts. However, containers cannot access this shared directory due to SELinux policy:

  avc: denied { read } for name=".empty-directory"
  scontext=container_t:s0:c139,c767 tcontext=container_var_run_t:s0

Without this policy, the optimization falls back to individual tmpfs mounts, negating the performance benefits.

Summary by Sourcery

Bug Fixes:

  • Grant container_t permission to read and search the shared .empty-directory under /run for masked path optimization

Copy link

sourcery-ai bot commented Aug 30, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updated SELinux policy to grant container_t read access to the shared empty-directory under container_var_run_t, enabling crun’s masked-path optimization to use a shared directory instead of fallback tmpfs mounts.

File-Level Changes

Change Details Files
Allow container processes to read the shared empty directory by extending SELinux rules
  • Add allow rule for container_t to read container_var_run_t directories
  • Grant read permission on the .empty-directory label
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

…timization

Problem: crun PR #1859 (containers/crun#1859) optimizes
masked paths by using a shared empty directory instead of individual tmpfs mounts.
However, containers cannot access this shared directory due to SELinux policy:

  avc: denied { read } for name=".empty-directory"
  scontext=container_t:s0:c139,c767 tcontext=container_var_run_t:s0
Without this policy, the optimization falls back to individual tmpfs
mounts, negating the performance benefits.

Signed-off-by: Sohan Kunkerkar <sohank2602@gmail.com>
@sohankunkerkar sohankunkerkar force-pushed the fix-selinux-for-shared-dir branch from 0fe3a9b to 0a82f95 Compare August 30, 2025 18:48
Copy link

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

@sohankunkerkar sohankunkerkar changed the title Allow container access to runtime directories for crun masked path optimization [WIP] Allow container access to runtime directories for crun masked path optimization Aug 30, 2025
@sohankunkerkar sohankunkerkar changed the title [WIP] Allow container access to runtime directories for crun masked path optimization Allow container access to runtime directories for crun masked path optimization Sep 1, 2025
@sohankunkerkar sohankunkerkar marked this pull request as ready for review September 1, 2025 13:08
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

openshift-ci bot commented Sep 1, 2025

@sourcery-ai[bot]: changing LGTM is restricted to collaborators

In response to this:

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.

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.

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.

@openshift-ci openshift-ci bot added the lgtm label Sep 1, 2025
Copy link

openshift-ci bot commented Sep 1, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lsm5, sohankunkerkar, 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

@openshift-ci openshift-ci bot added the approved label Sep 1, 2025
@lsm5
Copy link
Member

lsm5 commented Sep 1, 2025

/hold

@openshift-merge-bot openshift-merge-bot bot merged commit 20230f8 into containers:main Sep 1, 2025
29 checks passed
@lsm5
Copy link
Member

lsm5 commented Sep 1, 2025

ugh, looks like i was too late to add the hold. I should update the merge bot config to only use slash-lgtm as an official lgtm.

If anybody objects to the change, I'll post a revert, so lmk.

@sohankunkerkar
Copy link
Member Author

module crun_thermal_fix 1.0;

require {
    type container_t;
    type container_var_run_t;
    type container_file_t;
    class dir { read open search getattr };
}

# Allow containers to access shared runtime directories for crun masked path optimization
# This enables the thermal_throttle sharing fix for CNV scenarios
allow container_t container_var_run_t:dir { read open search getattr };
allow container_t container_file_t:dir { read open search getattr };

This policy worked well while testing on the real clusters.

@lsm5
Copy link
Member

lsm5 commented Sep 3, 2025

/cherrypick rhaos-maint

@openshift-cherrypick-robot

@lsm5: new pull request created: #396

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.

3 participants