Skip to content

lsm: Explain a failure to enter install_t and log it to the journal - #2696

Open
varuniyer wants to merge 1 commit into
bootc-dev:mainfrom
varuniyer:selinux-install-t-error
Open

varuniyer wants to merge 1 commit into
bootc-dev:mainfrom
varuniyer:selinux-install-t-error

Conversation

@varuniyer

@varuniyer varuniyer commented Nov 25, 2026 •

Copy link
Copy Markdown

When a systemd unit starts bootc from a script or a shell, bootc runs in unconfined_service_t or initrc_t and re-executes a relabeled copy of itself from $TMPDIR. On a noexec $TMPDIR that fails with only execve: Permission denied.

This follows up on the review of #2692, which closed a lint for this case as too heuristic. Instead of guessing at build time, bootc now explains the failure when it happens:

  • The error names the SELinux context bootc ran in, the copy it tried to execute, the likely cause, and the two fixes: run bootc directly from ExecStart=, or add the transition from Allow initrc_t and unconfined_service_t to transition to install_t fedora-selinux/selinux-policy#3327. The execve error stays in the message, so the assertion in tests: Verify a policy module lets wrapped bootc enter install_t #2689's test still matches.
  • bootc writes the same message to the journal at error priority with MESSAGE_ID=6ef49a449e1140d8835ada26ce80e0b9 and the context in BOOTC_SELINUX_CONTEXT, since a wrapper script may discard bootc's stderr. It goes through journal_send, as bootc-log-boot does, so the ID lands in a standard MESSAGE_ID field.
  • bootc-compatible-images(7) gains a "Running bootc from a systemd unit" section with the journalctl query and the fixes.
  • Test 71 runs bootc status from a bin_t wrapper with a noexec TMPDIR, then checks the error and the journal entry.

Tested: the lsm unit tests pass, and clippy reports nothing in the changed files. The booted test has only been run by CI.

Generated-by: AI
I reviewed it carefully.

The SELinux policy moves bootc into `install_t` when systemd executes
it directly. A unit that starts bootc from a script or a shell runs it
in `unconfined_service_t` or `initrc_t`, and bootc then re-executes a
relabeled copy of itself from `$TMPDIR`. When `$TMPDIR` is mounted
`noexec`, that fails with only `execve: Permission denied`, which names
neither the cause nor a fix.

The error now names the SELinux context bootc ran in, the copy it
tried to execute, the likely cause, and both fixes: run bootc directly
from `ExecStart=`, or add the transition that
fedora-selinux/selinux-policy#3327 adds to the base policy. The
`execve` error stays inside the message.

bootc also writes the message to the journal at error priority, with
`MESSAGE_ID=6ef49a449e1140d8835ada26ce80e0b9` and the context in
`BOOTC_SELINUX_CONTEXT`. A wrapper script may discard bootc's stderr,
and the fixed ID lets `journalctl MESSAGE_ID=...` find the entry. The
entry goes through `journal_send` rather than `tracing`, as the boot
journal entry does, so the ID lands in a standard `MESSAGE_ID` field.

bootc-compatible-images(7) documents the requirement, the journal
entry, and the fixes. Test 71 runs `bootc status` from a `bin_t`
wrapper with a `noexec` `TMPDIR` and checks the error and the journal
entry.

The lsm unit tests pass, and clippy reports nothing in the changed
files. The booted test has not run outside CI.

Generated-by: AI
Signed-off-by: Varun Iyer <viyer9@uic.edu>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:10

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.

@github-actions github-actions Bot added the area/documentation Updates to the documentation label Nov 25, 2026
@bootc-bot
bootc-bot Bot requested a review from gursewak1997 November 25, 2026 19:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants