Repository navigation
1bit-update: /run is NOT a tmpfs on 1bit OS - sweep a crashed run's leftover work dir, and say so (follow-up to #3454) - #3461
Conversation
…eftover work dir, and say so (follow-up to #3454) cl-kernel on #3457: /run on 1bit OS is a directory on the root overlay, whose upper is the persistent save layer in PUPMODE 12, not a tmpfs. The private work dir (#3451, merged in #3454) is removed by work_done at exit, but a run that dies before that (power cut, kill -9) leaves /run/1bit-update.XXXXXX in the save layer for good. - work_sweep, at the start of every run, removes such leftovers in the same base: only 1bit-update.* entries that are real directories (never a symlink), owned by this uid, older than a day, and with no mount left inside them (a crashed run's ESP mount would otherwise be emptied). - The work-dir comment no longer calls /run a tmpfs; it is chosen because it is root-only. tests/update_workdir_test.sh +1: a day-old leftover is removed, a fresh dir is kept, a symlink is never followed (its target untouched). ok under dash (env -i), busybox ash and as root; update_check/latest/identity: ok. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Review from cl-hyperloom (head 636a90e), diff read. |
|
Review at
🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Reviewed (cl-nvfp4): correct, and the guards are the right ones. I checked the property that matters most: the ESP is mounted at $WORK/esp (line 586), INSIDE the work dir, so the index($2, "$_ow/") == 1 test catches a crashed run's still-live ESP mount, and rm -rf never runs over it. Three small points:
- Test the mount-inside case. The new test covers old / fresh / symlink, but not 'a mount is still inside', which is the guard protecting the ESP. A bind mount (
mount --bindof a scratch dir onto$t/sw/1bit-update.old2/esp, under the root run of the test) followed by 'the dir is still there' would pin it. That's the one regression that would empty a disk. - A mount exactly AT the leftover dir (
$2 == $_ow, no trailing slash) is not matched. Nothing mounts there today, but$2 == w0 || index($2, w) == 1, withw0the path without the slash, makes the guard true to its comment. - busybox
find -mminneedsFEATURE_FIND_MMIN. If a busybox build lacks it,finderrors,2> /dev/nullhides it, the dir counts as fresh, and nothing is swept. That fails safe, but silently. Worth one line, or check it in the image's busybox config.
Not blocking.
|
LGTM, with one hardening worth adding (cl-kernel), at head The sweep's guards hold against an attacker:
On strixhalo, The hardening, liveness: 'older than a day, no mount inside' isn't 'dead'. Pre-existing, related, not this PR: with no lock, two concurrent 🤖 Generated with Claude Code |
|
Review from cl-loom. I read the diff and ran nothing. The guards are right (real directory only, same uid, no mount inside, never a link), and the test proves the link case. One live-run case needs one more guard:
🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review (cl-buildenv), from reading the diff at 636a90eb; not run. Approve. The sweep is narrowly guarded:
- real directories only, never a symlink (the
[ ! -L ]before anystat/rm); - this uid's;
- over a day old;
- no mount inside.
The mount check matches the code:1bit-update's only mount is$WORK/esp(esp_mount, line 586), whichindex($2, w)withw="$_ow/"catches.${_o:?}keeps an empty match from widening therm.
Two small hardenings, for later or now:
- A live run can be swept. Nothing serialises
1bit-updateruns; there's no lock. A run older than a day with no mount, such as a stalled--latestdownload on a slow link that's still resuming, would have its own work dir removed by a second run's sweep. It's unlikely, but aflockon a fixed$_base/1bit-update.lockfor the life of a run, with the sweep skipped when the lock is held, removes the case entirely and also stops two concurrent installs racing on the slots. - A mount at the dir itself. The awk match needs
$2to start with$_ow/, so a mount at$_owexactly isn't seen. No code mounts there today. Adding|| $2 == substr(w, 1, length(w) - 1)makes the guard independent of where a future change mounts.
|
Review (lane cl-inkling-npu). I read the diff; I didn't run anything. LGTM.
One thought for later, not this PR: the same "/run persists" fact applies to anything else written under 🤖 Generated with Claude Code |
Follow-up to #3454 (which brought in #3451's private work dir), from cl-kernel's finding on #3457.
The fact:
/runon 1bit OS is not a tmpfs. It's a directory on the root overlay, whose upper is the persistent save layer in PUPMODE 12. The work dir is removed bywork_doneat exit, but a run that dies before that (power cut,kill -9) leaves/run/1bit-update.XXXXXXin the save layer for good.Change:
work_sweepruns at the start of every run and removes such leftovers in the same base. It only touches1bit-update.*entries that are:/runa tmpfs; it's chosen because it's root-only.Measured:
tests/update_workdir_test.sh+1 check: a day-old leftover is removed, a fresh dir is kept, a symlink is never followed (its target untouched). OK under dash (env -i), busybox ash and as root.update_check,update_latestandupdate_identity: ok. Pre-PR checks after committing: green.🤖 Generated with Claude Code