Repository navigation
tools/mark-slot-b and push over UFS_RW_LUNS, inert until the §3.1 entry (part 1 of #616) - #651
matthewjaybarr-png wants to merge 5 commits into
Conversation
|
Thank you, @matthewjaybarr-png. This is the split I asked for, and done cleanly: nothing sets Two things I'd like in the tool before I merge it, while it is still inert: 1. A
After a dropped cable mid-write the only way on would be a 2. The test passes with most of the checks removed. I took these out one at a time and
It does catch the slot check, the phone check, the confirmation, the cut transfer, wrong LBAs, differing arrays and an inactive Smaller things, for this PR or part 3, your choice:
|
91fb236 to
e1a096d
Compare
|
Thanks. Pushed, rebased on today's main (
Smaller ones: the |
|
Thank you, @matthewjaybarr-png. This is a careful answer to both points. The tests. I took 22 things out of the tool one at a time, the nine from last time among them, and The recovery. Saving the old and new sectors first, recognising a half-written table against them, and offering to finish or restore under the typed confirmation is what I asked for. I cut the first write before the 2nd, 3rd and 4th sector and ran both choices from each: all six end on the right image, byte for byte. One thing in it has to change before I merge, and it's the kind of thing only the recovery could have introduced. The mirror image exists too: a restore from that state cut before its 3rd write leaves the primary valid and the backup broken, and The fix is small: bring a torn copy to the target first, so the good copy is never touched while it's the only one. pairs = [(want[1], want[0]), (want[2], want[3])]
# a copy with one sector old and one new is already invalid: make it whole first
pairs.sort(key=lambda pr: len({cur[l] == target[l] for l in pr}) == 1)
for pair in pairs:I ran that: the same 140 walks find no such state, a fresh mark keeps its primary-then-backup order, and your test passes unchanged. Please add a case that checks, after every single write of a finish and of a restore from each mixed state, that at least one copy has a valid header CRC and entry-array CRC; and change the NOTES sentence "so a valid copy exists at every moment" to what the tool then guarantees. Smaller things, for this push if you can:
The The rule and the entry are still mine. Your numbers will go into it as they are (LBA 1, 3, 786428 and 786431 on |
- 6-vs-7 partition discrepancy resolved from source (device.conf:90-91: 6 NV_PARTS + devinfo extra = 7 dumped, 6 consumed). - NEW-2 tested empirically: duplicate UFS_RW keys are last-wins in all three parsers (no desync); install-phone and omamobile refuse the hostile value fail-closed; the true differential is bundle-manifest's missing every-entry rule — covered by the installer's flash gate and plan equality. proof/duplicate-key-check.sh records it. - Check 17 added to the battery: --unsigned --reinstall + boot_a/persist manifest writes refused at allowlist equality. Battery now 16/16. - Severity re-rulings recorded (S-1 Medium, S-7 Medium with Layer-3 boundary correction), NEW-1 implemented on the fix branch, derekross#651 verdict amended (stable-LUN-identity ask), S-3 pre-seed design filed.
e1a096d to
bb532d3
Compare
|
Thanks, all done in bb532d3 (rebased onto main, so it needs a force push):
I left the rule text alone. |
|
Thank you, @matthewjaybarr-png. Everything from the last round is in, and I checked each one by taking it back out. The one that mattered: with your sort removed from
The red check on this push is not yours. Part 3 then carries what we agreed: what your bootloader passes as |
push looked for <image>_b only under /sys/block/sda. It now looks on sda and on each LUN in UFS_RW_LUNS, the same LUNs the init guards, and refuses a name found on more than one partition or a path it doesn't expect. No descriptor sets UFS_RW_LUNS yet, so every lookup today is the sda one it was; enchilada's sde comes with its slot-B install, after its CONTRIBUTING §3.1 entry. tests/images-layout: the fake phone places partitions on one LUN; push finds them on a UFS_RW_LUNS LUN, not on a LUN the descriptor doesn't name, and refuses a duplicate name before writing anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a Qualcomm A/B phone slot B is marked successful in its GPT, which the storage guard can't police, so the write gets its own tool, run by hand once per install of slot B's boot image and never from a service. It is inert until a device has its §3.1 entry: no descriptor sets SLOT_B_MARK, and without it the tool refuses. The descriptor would name the write (SLOT_B_MARK: the LUN, the partition and the four LBAs). Over phone-ssh the tool first checks that the phone's first /proc/device-tree/compatible string is the descriptor's COMPATIBLE, before anything makes a node. It then reads both GPT copies through a private whole-disk node under /run, checks both headers, both entry arrays and their CRCs, finds the partition by name once, and refuses unless its sectors are the named four, the phone booted slot B, and B is active and not unbootable. It sets bit 54 and nothing else, recomputes the entry-array CRC and both header CRCs, and checks that only those four sectors change. The default is a dry run; --write asks for 'mark boot_b', re-reads the four sectors, writes the primary pair, reads it back, then the backup pair. No sector is piped over SSH into the disk: each lands in a file in the private directory, its SHA-256 is checked on the phone, and dd writes it from that file. tests/mark-slot-b runs it against a synthetic 4096-byte-sector GPT behind a fake phone-ssh, including another phone, a transfer cut short and each refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What a §3.1 entry for boot_b needs from this phone, read-only: sde's geometry and boot_b's place in both GPT copies, the 72 partitions sde holds by PARTNAME (abl_a and abl_b among them, xbl not), and so what a whole-disk sde node reaches. With abl on sde, a phone left with no valid table there has no rescue and no fastboot, only Qualcomm EDL; the notes say so. The attribute bits are cited from Qualcomm's ABL, and only a getvar after a write would prove bit 54 on OnePlus's build of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A --write cut off after its first, second or third sector left a table that every later run refused, and the only way on was a dd by hand. The tool now saves the four old and new sectors on the laptop before it writes (off the repository, as they hold the disk's GUID, with a SHA256SUMS as CONTRIBUTING §3.3 asks of backups). The next run recognises a half-written table and offers to finish the write or put the old sectors back, under the same typed confirmation. It also refuses early when the LUN is not in UFS_RW_LUNS or is read-only, and reads with iflag=direct so the read-back sees the disk, not the page cache. The test passed with most checks removed. It now has a case for each: a table changed between check and write, a write that does not land, each bad CRC, headers that do not describe each other, the last LBA, two boot_b, bit 55, the internal byte check, the dd order, O_DIRECT reads and a damaged saved sector, plus finish and restore after a cut at each sector. Each check was removed in turn and the test failed every time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A copy with one sector old and one new is already invalid, so a finish or a restore that started on the other copy could leave no valid copy at all. apply() now sorts the pairs so a torn one is written first, and the test checks, after every single write of a finish and a restore from each of the 14 mixes of old and new sectors, that one copy still has a valid header CRC and entry-array CRC. The NOTES say what that guarantees. Also from the review: an earlier saved set is kept under a dated name rather than deleted; a write that fails on a dropped link says not to restart the phone but to run the tool again; calls that send no data get stdin from /dev/null, so phone-ssh cannot swallow a piped confirmation; the tests assert fsync on the write and the header's own-LBA check; and tests/mark-slot-b has its own lines at the end of tests/all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bb532d3 to
a6b59c4
Compare
|
Rebased onto current main. The only conflict was the test list in |
What and why
Part 1 of the split asked for on #616: the push change and
tools/mark-slot-bwith its test, inert until enchilada has its CONTRIBUTING §3.1 entry. No descriptor setsUFS_RW_LUNSorSLOT_B_MARK, andAGENTS.mdandCONTRIBUTING.mdare untouched; the rule and the entry are the maintainer's, after #639.Changes from #616, per its review:
mark-slot-bcompares the first/proc/device-tree/compatiblestring with the descriptor'sCOMPATIBLEbefore it makes the node, as the init does. Tested: anacme,otherphone is refused and the log shows nomknod.ddwrites from that file. Tested: a transfer cut to 100 bytes fails with "arrived damaged on the phone; nothing written", the disk is unchanged, and the private directory is gone. Everydd of=in a real--writeisdd if="$d/sector".sde's 72 partitions byPARTNAME, and so what the private whole-disk node reaches.abl_aandabl_bare onsde;xblis not, and its LUN is still to be read on the phone. The "both copies invalid" case now says what it really means: no rescue, no fastboot, only Qualcomm EDL. The bit layout is cited from Qualcomm ABL'sPartitionTableUpdate.h.docs/RELEASES.md:SLOT_B_MARKis documented as set only once a device has its entry, and none does.Before/after, on this branch:
sdenode on whatevertools/phone-sshreached, and--writepiped each sector straight intodd.ok - mark-slot-b: phone check, dry run, confirmation, checked sector files, bit 54 on boot_b in exactly LBA 1,3,16381,16383, and its refusals.I checked by mutation that the test catches both regressions. With the old pipe write, it fails "--write takes a sector cut short". Without the compatible check, it fails "marks another phone".
Merge danger: low. Nothing on a phone changes until a descriptor sets these keys, which waits for the §3.1 entry. The push lookup over
sdais as it was, andtests/images-layoutstill covers it.Device and build
uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpassestests/packagespasses (or the packages I touched: none)versionbumped, and the new version is in the commit subject (no packages changed)Co-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
xbl's LUN is not yet readuserdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1).mark-slot-bis the write the §3.1 entry will name, and without that entry it refuses.🤖 Generated with Claude Code