Repository navigation
Description
This text was generated by an LLM (how cgwalters uses LLMs). cgwalters has not reviewed it yet.
pr = "ostreedev/ostree#3649"
head = "a0207f11818b46729249315399c87fe99d5e3f21"
event = "REQUEST_CHANGES"
Review
AI: Thanks for picking this up, and for the clear reproduction in #3563. Unfortunately I don't think this approach can go in as written, for a few reasons.
First, the PR doesn't build. The new code calls glnx_file_get_contents_utf8_at() with the wrong arguments and uses g_auto(GString) / G_STRING_INIT, which don't exist, so every SELinux-enabled build job fails. The clang-format job also fails, because the branch reformats unrelated code in ot-main.c, ostree-sysroot-upgrader.h and ostree-repo-finder-mount.c, apparently with a different clang-format version than the one CI uses. Please drop those hunks.
Second, I don't think the tmp/ pruning addresses the reported failure. libsemanage's semanage_make_sandbox() already deletes any existing <store>/tmp and re-copies active/ into it at the start of every transaction. So the tmp/modules/200/.../lang_ext path in the error is a fresh copy of an active/modules tree that is already incomplete. My best guess is that the real cause is the per-file 3-way /etc merge running over the module store. If one file in a module directory was modified locally and the others weren't, the merge can delete some files and keep others, which leaves a half-removed module in active/. Nothing in this PR touches active/.
Third, making the refresh failure non-fatal is the part I'm most worried about. The "previously built binary policy carried over via /etc" is whatever the merge kept in /etc/selinux/<type>/policy/. On any system where policy was ever rebuilt locally (a module install, or setsebool -P), that file is the user's modified copy built from the old image's policy. The new deployment would then boot with the old policy and none of the new image's policy changes. That's a silently stale or mismatched policy in enforcing mode. The only notice is a warning printed by ostree-finalize-staged during shutdown, where nobody will see it. Trading a visible "can't update" for a possibly unbootable or mislabeled system isn't a good trade. I'd rather keep this fatal and move detection earlier, as discussed in the issue: try a dry-run policy build when staging and refuse to stage if it fails, so the error reaches the user while they're watching. The longer-term fix is the /usr vs /etc split for image-provided modules.
A separate, smaller change that does seem worth taking is the one alexvarming described: skip the refresh when the deployment has no active module store for the configured SELINUXTYPE. Images with only a compiled policy can't usefully run semodule --refresh anyway. That should be its own PR, with a test.
There are no tests here. Any version of this needs at least a kola test that reproduces the broken-store case, e.g. by deleting one file from an active/modules/<prio>/<name> directory in /etc before staging. Please also rebase to drop the merge commits and squash the fixups into one logically described commit.
Comments
src/libostree/ostree-sysroot-deploy.c:3415
This stats and removes tmp relative to the /etc/selinux dirfd, so it's checking /etc/selinux/tmp, not /etc/selinux/<store>/tmp. Even with the path fixed, libsemanage removes and recreates the sandbox from active/ at the start of every transaction (semanage_make_sandbox()), so a leftover tmp/ can't cause the failure in #3563. I'd drop this function.
src/libostree/ostree-sysroot-deploy.c:3521
Execution only reaches this point when exists_in_new is false, i.e. new_upstream_file doesn't exist, so this read always fails with ENOENT. The whole cleanup pass then aborts and gets logged as a warning. Separately, rewriting files under /etc by deleting any line that appears in the old /usr/etc copy is risky: it can silently drop user configuration. It also only looks at top-level regular files in /etc/selinux/<store>/, while the module store lives under active/modules/<prio>/<name>/. I don't think this function should be kept in any form.
src/libostree/ostree-sysroot-deploy.c:3458
(low) new_upstream_exists is never used, and new_upstream_dir/old_upstream_dir build the same string. Moot if the function goes away.
src/libostree/ostree-sysroot-deploy.c:3641
This also makes it non-fatal when semodule --help itself fails to spawn. That covers bwrap failing in the new deployment, which is a real problem we want to surface, not something to skip quietly.
src/libostree/ostree-sysroot-deploy.c:3668
Important: This is the core concern: on failure we finalize with whatever policy.NN the /etc merge kept. On a system with any local policy change, that's a binary built from the previous image's policy, so the new deployment runs with stale policy. Please keep this an error, and catch it at stage time (dry run) rather than downgrading it at shutdown.
- Send the newest draft as cgwalters-bot
Activity
cgwalters-bot commentedon Nov 7, 2026
✅ dispatch ended well. Result: #862 (comment)
cgwalters-bot commentedon Nov 7, 2026
Valid and still actionable; not done or obsolete. PR #3649 is open at the draft’s exact head,
a0207f1, with no submitted reviews. The build defects are independently confirmed by the existing Fedora CI log: wrongglnx_file_get_contents_utf8_atarguments and invalidGStringinitialization. That is CI reproduction, not a fresh local build. The deployment failure has reported reproduction and recovery steps; I did not reproduce it in a VM.The code supports the main objections: pruning uses the parent SELinux dirfd rather than the store dirfd; cleanup reads
new_upstream_fileonly after establishing it is absent; refresh/spawn failures become success. Fixing compilation alone would not make that safe. One draft nit should be corrected before sending: identical old/new path strings are intentional because they are resolved against different deployment dirfds, not themselves a defect. The precise merge-to-incomplete-store mechanism and stale-policy boot consequences remain hypotheses needing integration tests.Accept a bounded OSTree implementation follow-up, following cgwalters’s stage-time validation direction, rather than accepting fail-open finalization. Account separately for the compiled-policy-only report. This is not a tracker code defect, nor authorization to send this review; sending remains the explicit review-send action.
Generated-by: https://github.com/cgwalters/#llms