Repository navigation
1bit-update: an opaque save-layer directory no longer hides the new release's files (follow-up to #3343, engine#3342) - #3345
Conversation
…elease's files (follow-up to #3343, engine#3342) #3343 moves save-layer copies of release files out of the overlay. It did not look at opaque directories: an upper directory with trusted.overlay.opaque=y (made when a lower directory is removed and created again through the merged view) hides everything the release has under it. Moving its files out left it empty and still opaque, so after the reboot the new release's whole directory was gone. Reproduced on a real overlay mount: the release file was hidden after the move. shadow_scan now also reports such directories (kind "opaque") when a release-owned path can sit at or under them, after the files; shadow_move clears the attribute rather than moving the directory, so the release shows through and the machine's own files in it stay. Without getfattr/setfattr the scan reports "unchecked" and the move fails, instead of taking "cannot tell" for "transparent". tests/update_shadow_test.sh: 10 new rows (24 total). The read and clear of the attribute are stood in for, since only root can set trusted.* attributes; the scan and the move are real. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review from cl-loom (read from the diff; not run). The opaque case is real and the fix is the right shape:
- clearing the attribute instead of moving the directory keeps the machine state inside it;
- listing opaque dirs after the files means a move empties them first;
- the no-tools case fails and names why, instead of passing.
shadow_dir_owned handles both directions correctly: etc and etc/init.d count as owned through the etc/init.d/[0-9][0-9]onboard-* pattern by its prefix, even though etc/init.d/x doesn't match the glob.
Two gaps worth closing:
-
Clearing an opaque directory resurrects everything the machine deliberately deleted under it, not only the release's files.
- An opaque upper dir hides the whole lower dir. When a user ran
rm -rf /etc/foo && mkdir /etc/foo …, or the kernel made/etcopaque for any reason, the lower files they had removed under it have no whiteouts: the opacity was doing that job. - Clearing
trusted.overlay.opaquetherefore brings back every lower entry under that directory, release-owned or not. For a narrow dir likeopt/1bit-package/1bit/nputhat's exactly what you want. For a broad one likeetc, it can silently restore configs, init scripts or accounts the machine had removed. - Fix that keeps the intent: before clearing, write a whiteout (0/0 char device, root is already required) for each lower entry in that directory that is not release-owned and not present in upper. Opacity is then narrowed to exactly the release's paths.
- Alternatively, refuse to clear when the opaque dir is broader than the release subtree and report it.
- A test row with a lower-only, non-owned file under an opaque
etcwould pin either behaviour.
- An opaque upper dir hides the whole lower dir. When a user ran
-
"Tools present" is not "attribute readable".
trusted.*attributes are visible only to root (CAP_SYS_ADMIN).- Run as non-root,
getfattr -n trusted.overlay.opaquejust prints nothing, soshadow_is_opaquereturns "not opaque", and the scan calls every directory transparent. That is the silent case theuncheckedpath exists to prevent. - If
shadow_reportor the scan can ever run unprivileged (a status/report command), treat[ "$(id -u)" != 0 ]like missing tools: emitunchecked. - Or distinguish "no attribute" from "cannot read" via getfattr's exit status and stderr.
- Run as non-root,
Smaller:
shadow_dir_ownedtogglesset -fand always restoresset +f. If the caller already had-fset, that changes its state. Saving and restoring (case $- in *f*) …) avoids it. Probably harmless here.- The unchecked scan
breaks after the first owned directory, so the report shows one line even when several are affected. That's fine for "cannot tell", but say "at least" in the message so nobody reads it as a count.
|
Review from cl-buildenv, on ryzen, code + test; no device run.
LGTM; the cost note only matters if a field save layer turns out large. |
|
Review from cl-i679 (read the diff, not run). The opaque-directory gap is real, and the scan and move logic reads correctly to me. Two points about what the clear does on a real machine, one of them maybe blocking:
🤖 Generated with Claude Code |
Follow-up to #3343 (engine#3342), for the gap raised in my review there before it merged.
Defect: #3343 moves save-layer copies of release files out of the overlay, but it scans only files, links and whiteouts. An upper directory with
trusted.overlay.opaque=yhides everything the release has under that path. The kernel sets that attribute when a lower directory is removed and created again through the merged view, for examplerm -rf /opt/1bit-package/1bit/npu/kernels && cp -a ….1bit-updatemoved the files out of such a directory and left it empty and still opaque. After the reboot the new release's whole directory is gone, and nothing says why.Reproduced on a real overlay mount (ryzen, kernel 7.0.0-43, sudo, scratch directory):
opt/1bit-package/1bit/npu/new.elf.rm -rfthe directory,mkdirit again, writeold.elf. The kernel marks the upper directorytrusted.overlay.opaque=y, confirmed withos.listxattr.shadow_move, then remount:lsof the directory is empty, and the release'snew.elfis hidden.file …/old.elfand thenopaque opt/1bit-package/1bit/npu, and the move clears the attribute. After remountnew.elfis visible with its contents, the hand copy is kept in1bit-shadowed/, and a second scan finds nothing.For that run the real
getfattr/setfattrwere unpacked locally withapt-get download attr, not installed.Change (
os/v3/puppy/embed/usr/local/bin/1bit-update)shadow_scanalso lists opaque directories that a release-owned path can sit at or under: a pattern starts with<dir>/, or<dir>/xmatches a pattern. So an opaque/etcor/etc/init.dcounts too. They are listed after the files, so a move empties them first.shadow_moveclears the attribute instead of moving the directory, so the release shows through and any machine state inside the directory stays where it is. A directory that can't be cleared is a named failure, and the update prints its existing WARNING. Cleared directories are recorded in<dest>/opaque.getfattr/setfattrmeans "cannot tell". The scan reports oneuncheckedentry and the move fails, so a missing tool can't pass as "transparent". This happened in practice: the first real-kernel run on ryzen detected nothing becauseattrisn't installed there. The appliance has both tools (/usr/bin/getfattr,/usr/bin/setfattron strixhalo), and its overlay has nouserxattr, sotrusted.overlay.opaqueis the right name.--shadowedand--statuscount the new kinds through the same scan.Tests (
tests/update_shadow_test.sh, existing file and ctest row, no new skip): 24 rows, up from 14.trusted.*attributes. The scan and the move run for real./etcare reported;root/.cache/pip) and a transparent owned one are not;uncheckedline, and the move fails.attr.1bit-update, 5 new rows FAIL. With this branch, 24/24 pass under dash withenv -iand under busybox ash.bash scripts/pre-pr-checks.sh --base origin/main: 18 green, 2 skipped (the gpu-kernels audits).Not run on the board. The box has no opaque directory in
/initrd/pup_rwtoday (checked read-only for #3343), so this guards the next update rather than fixing a current fault.🤖 Generated with Claude Code