Skip to content

Conversation

@ca-hu
Copy link
Contributor

@ca-hu ca-hu commented Dec 8, 2025

…1253682)

For some reason it is not listed in the file contexts, so it will show up as to be relabelled when running "restorecon":

Would relabel /home/foo/.local/share/containers/storage/overlay-containers/f857f27662ab22b7c502a531d61790b7c120dbedc70820962bb45c285aa03cc3/userdata/artifacts from unconfined_u:object_r:container_ro_file_t:s0 to unconfined_u:object_r:data_home_t:s0 Would relabel /home/foo/.local/share/containers/storage/overlay-containers/2b562de7757133521824ac9de932ddd4862d8262695998a4ee02094c14fc1277/userdata/artifacts from unconfined_u:object_r:container_ro_file_t:s0 to unconfined_u:object_r:data_home_t:s0

-containers is defined here:
https://github.com/containers/storage/blame/83cf57466529353aced8f1803f2302698e0b5cb7/store.go#L3633

Summary by Sourcery

Bug Fixes:

  • Prevent incorrect relabeling of ~/.local/share/containers/storage/overlay-containers paths by defining appropriate file contexts.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 8, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Add SELinux file context entries for Podman/containers-storage overlay-containers paths under users' ~/.local/share directories so restorecon no longer attempts to relabel them to data_home_t.

File-Level Changes

Change Details Files
Define SELinux file context patterns for per-user containers-storage overlay-containers content under ~/.local/share to keep them labeled with container_ro_file_t.
  • Add regex-based path mapping for ~/.local/share/containers/storage/overlay-containers to container_ro_file_t
  • Align new path definition with existing -containers convention used by containers/storage
container.fc

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 addresses an SELinux relabeling problem affecting user-specific container storage. By explicitly defining the correct file contexts for overlay-containers and overlay2-containers within the container.fc configuration, it ensures that restorecon maintains the intended container_ro_file_t context. This prevents unnecessary and potentially problematic security context changes, thereby improving the stability and correctness of SELinux enforcement for container users.

Highlights

  • SELinux File Context: Added SELinux file context rules for ~/.local/share/containers/storage/overlay-containers and ~/.local/share/containers/storage/overlay2-containers to the container.fc file.
  • Relabeling Issue Fix: This change resolves an issue where the restorecon utility would incorrectly relabel files within these container storage directories, changing their security context from container_ro_file_t to data_home_t.
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.

…1253682)

For some reason it is not listed in the file contexts, so it will show
up as to be relabelled when running "restorecon":

Would relabel /home/foo/.local/share/containers/storage/overlay-containers/f857f27662ab22b7c502a531d61790b7c120dbedc70820962bb45c285aa03cc3/userdata/artifacts from unconfined_u:object_r:container_ro_file_t:s0 to unconfined_u:object_r:data_home_t:s0
Would relabel /home/foo/.local/share/containers/storage/overlay-containers/2b562de7757133521824ac9de932ddd4862d8262695998a4ee02094c14fc1277/userdata/artifacts from unconfined_u:object_r:container_ro_file_t:s0 to unconfined_u:object_r:data_home_t:s0

<driver>-containers is defined here:
https://github.com/containers/storage/blame/83cf57466529353aced8f1803f2302698e0b5cb7/store.go#L3633

Signed-off-by: Cathy Hu <[email protected]>
@ca-hu ca-hu force-pushed the main-overlay-label-mismatch branch from 5dae7be to 6e2a14b Compare December 8, 2025 12:34
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 correctly adds the missing file contexts for ~/.local/share/containers/storage/overlay-containers and overlay2-containers, which resolves the issue of incorrect relabeling by restorecon. The change is straightforward and necessary. I've added one comment regarding the sorting of entries in container.fc for future maintainability improvements, but it doesn't block this PR.

Comment on lines +103 to +104
HOME_DIR/\.local/share/containers/storage/overlay-containers(/.*)? gen_context(system_u:object_r:container_ro_file_t,s0)
HOME_DIR/\.local/share/containers/storage/overlay2-containers(/.*)? gen_context(system_u:object_r:container_ro_file_t,s0)

Choose a reason for hiding this comment

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

medium

The placement of these new lines follows the existing reverse-alphabetical sorting of suffixes for the entry pairs (layers, images, containers). However, this ordering is inconsistent with other files like container.if (lines 589-593), which use alphabetical order for these suffixes. For better long-term maintainability, it would be ideal to make the sorting consistent across the policy files. Consider creating a follow-up task to reorder this block alphabetically by suffix (containers, images, layers).

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

openshift-ci bot commented Dec 10, 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

@haircommander
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 10, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 9c3cc4c into containers:main Dec 10, 2025
31 checks passed
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