Skip to content

lints: Warn when a service wraps bootc in a generic-labeled program - #2692

Closed
varuniyer wants to merge 1 commit into
bootc-dev:mainfrom
varuniyer:lint-install-t-wrapper
Closed

varuniyer wants to merge 1 commit into
bootc-dev:mainfrom
varuniyer:lint-install-t-wrapper

Conversation

@varuniyer

Copy link
Copy Markdown

The SELinux policy moves bootc into install_t only when systemd executes it directly. A service that starts bootc from a shell or a script leaves it in the wrapper's domain, where it may lack the permission to write labels unknown to the running policy. Nothing reports this at build time, and the failure shows up later, during an update. See #2186 and #2366.

This adds an install-t-wrapper warning to bootc container lint.

What it checks

The lint reads the Exec*= lines of each service in /usr/lib/systemd/system and /etc/systemd/system. It warns when both of these hold:

  • The image's policy labels the program bin_t or shell_exec_t.
  • The command line, or a script it names, calls bootc.

A service that runs /usr/bin/bootc directly from ExecStart= draws no warning.

Scope

  • It covers bootc alone. A version that also matched ostree failed the CentOS Stream 9 builds under --fatal-warnings, because ostree-readonly-sysroot-migration.service there runs a bin_t script that calls ostree config.
  • It misses a wrapper that reaches bootc through a second script or through a binary.
  • It is a warning, and --skip install-t-wrapper turns it off.

It complements #2366 and #2689. Those make a wrapped bootc work, and this tells an image author that their service wraps it.

Testing

  • Four unit tests cover the unit-file parsing, the word match, the label parsing, and the script reader.
  • CI passes on my fork: https://github.com/varuniyer/bootc/actions/runs/45450806573
  • On registry.redhat.io/rhel10/rhel-bootc, the stock image draws no warning. With test services added, an inline sh -c "bootc upgrade", a script named in ExecStartPre=, and a bare bash /path/script.sh each warn, and a direct ExecStart=/usr/bin/bootc upgrade does not.

Generated-by: AI
I used AI to generate the code. I reviewed its functionality and cleanliness.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@bootc-bot
bootc-bot Bot requested a review from gursewak1997 November 24, 2026 21:53
@varuniyer

Copy link
Copy Markdown
Author

The two failing jobs are network errors: test-container-export got "unauthorized" pulling ubi9/podman from registry.access.redhat.com, and the CentOS 9 integration job hit an unexpected EOF from quay.io's CDN mid-layer. Could someone rerun them?

@45h0kg

45h0kg commented Nov 25, 2026

Copy link
Copy Markdown

Nice, this complements #2689 well. Some data points and one suggestion.

The domain mapping in GENERIC_EXEC_TYPES matches what I measured:

  • A bin_t wrapper script started by systemd runs as unconfined_service_t, and bootc status from it fails with execve: Permission denied when TMPDIR is noexec. That's in tests: Verify a policy module lets wrapped bootc enter install_t #2689's CI on c9s, c10s and f44 (ostree).
  • ExecStart=/bin/bash -c '...' runs as initrc_t and fails the same way. I checked this by hand on c10s.
  • Read-only commands are affected too: bootc status goes through prepare_for_write(), so matching any bootc call rather than only upgrade/switch seems right.

Suggestion: the lint can't tell when the transition has been added. An image that ships a policy module like the one in #2366/#2689 will still warn, and so will every wrapped service once fedora-selinux/selinux-policy#3327 reaches the base policies. Checking the compiled policy is probably too heavy for a lint. Could the help text mention the policy-module workaround next to --skip install-t-wrapper, with a note that the lint should be revisited once the base policy has the transition?

Two smaller gaps, fine to leave for later:

  • Drop-ins (*.service.d/*.conf) aren't scanned, and they're a common way to override ExecStart= in derived images.
  • read_script requires a #! line, so ExecStart=/bin/bash /usr/libexec/foo.sh with no shebang in foo.sh isn't checked. When the program is a shell, its script argument could be read regardless.

The SELinux policy moves bootc into `install_t` only when systemd
executes it directly. A service that starts bootc from a shell command
or a `bin_t` script runs it in `initrc_t` or `unconfined_service_t`,
and nothing tells the image's author.

The `install-t-wrapper` lint reads the `Exec*=` command lines of each
service and of its `*.service.d/*.conf` drop-ins, and asks the image's
policy for the label of the program that systemd executes. It warns
when that label is `bin_t` or `shell_exec_t` and the command line, or a
script it names, mentions bootc. A script that a shell runs is read
whether or not it has a `#!` line. A wrapper with a type of its own
passes, because its policy module owns its transitions. An image
without an SELinux policy passes.

An image can instead ship a policy module that lets
`unconfined_service_t` and `initrc_t` transition to `install_t`. The
lint reads only file labels, so its help text tells such an image to
pass `--skip install-t-wrapper`. A comment marks the lint for review
once fedora-selinux/selinux-policy#3327 adds those transitions to the
base policies.

The lint covers bootc alone. ostree and rpm-ostree share the
`install_exec_t` label, but CentOS Stream 9 ships
ostree-readonly-sysroot-migration.service, whose `bin_t` script calls
`ostree config`, and a warning there fails every build that runs the
lint with `--fatal-warnings`.

The lint misses a wrapper that reaches bootc through a second script,
and one that builds the command at run time. It reads each unit file
and drop-in on its own, so it still warns on a unit whose drop-in
replaces the wrapper with a direct call.

Tested by linting registry.redhat.io/rhel10/rhel-bootc. The image as
shipped draws no warning. Three added wrapper services (`sh -c`, a
script, and `bash` with a script argument) each draw one, and a direct
`ExecStart=/usr/bin/bootc` draws none. Also tested by linting
quay.io/centos-bootc/centos-bootc:stream10, which as shipped draws no
warning. A drop-in that runs `sh -c 'bootc upgrade --apply'` and `bash`
with a script that has no `#!` line each draw one, and `python3` with
that script and a drop-in that runs `/usr/bin/bootc status` draw none.

Generated-by: AI
Signed-off-by: Varun Iyer <viyer9@uic.edu>
@varuniyer
varuniyer force-pushed the lint-install-t-wrapper branch from 0fa1e7d to e606bc9 Compare November 25, 2026 13:10
@varuniyer

Copy link
Copy Markdown
Author

Thanks, all three were real. I pushed:

Tested on centos-bootc stream10: a drop-in running sh -c 'bootc upgrade' and bash with a script that has no shebang now each draw a warning. python3 with that script and a drop-in calling /usr/bin/bootc directly still pass.

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this contribution, but I think it's taking the scope of the lint tool beyond what I'm comfortable with, and it's too heuristic even then.

I think we just need to recommend people apply the selinux patch if they're affected now.

It's really unfortunate that it hasn't been fixed in base SELinux policy, but if that continues to be the case in say a month, then I would be in favor of encouraging downstreams to apply the patch or ship a custom selinux policy here.

(There is a large cost to custom selinux policy though)

Comment thread crates/lib/src/lints.rs
}

/// Whether shell text names bootc outside a comment line.
fn names_bootc(text: &str) -> bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems too likely to result in false positives.

In general, us parsing systemd units seems a bit beyond what I think this tooling should be doing.

@cgwalters

Copy link
Copy Markdown
Member

I cannot think of a way to really lint this in a way that's truly accurate, scraping ExecStart which might include shell script for the term bootc is just too heuristic to ship in my opinion. But feel free to reopen if you can think of a fundamentally different approach. Thanks!

@cgwalters cgwalters closed this Nov 25, 2026
@varuniyer

Copy link
Copy Markdown
Author

The one failure is plan-29-soft-reboot-selinux-policy on fedora-44/ostree/btrfs: after the reboot the host was still on localhost/bootc:latest with nothing staged. The change only touches bootc container lint, and the same plan passed on the xfs ostree jobs. Could someone rerun it?

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.

4 participants