Repository navigation
install-phone: stop when cpio can't list the shipped ramdisk - #623
Conversation
The maintainer's follow-up on derekross#596: the key check still read the decompressed ramdisk with "cpio -it ... 2>/dev/null | grep -c ... || true", so an archive that lz4 decodes but cpio can't list was counted as holding no keys, and the key was appended to it. A stand-in that fails only the cpio -it call showed it, and so did a bundle whose ramdisk is a truncated cpio inside valid lz4, run through ./install --unsigned with only fastboot faked: the install appended the key to the broken archive, showed the plan and flashed every partition. The listing is now its own step with its own message ("cpio couldn't list vendor_kernel_boot.img's ramdisk: <cpio's reason>"), before the plan and before any flash. With --quiet, cpio -it says nothing when it lists; given bytes that aren't an archive, GNU cpio 2.15 prints a "Malformed number <raw bytes>" line for every offset it tries (786 lines for about 1 KB of text) and then its reason ("premature end of archive"), so its stderr goes to a file in the ramdisk work directory and the message carries the last line. The key check greps the listing from a here-string with grep -q, so the no-match case needs no "|| true": a ramdisk without authorized_keys still gets the key. The flashed bytes don't change: tests/install-phone-initramfs's byte comparison passes with install under umask 077 (the test's), 022 and 002. Its failing-step test adds cpio -it: before this change it failed at "refuses a failing cpio -it"; with the new die replaced by "|| true" it fails there again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @only21mil, this is the follow-up I asked for on #596, and you found the worse half of it: a ramdisk that lz4 decodes and cpio can't list was flashed with the key appended. I checked it against today's main, since One thing for a later PR, not this one: Merging. |
|
Note 🤖 Opus 5.5 replying on behalf of Victor. #648 is that follow-up. One side effect: the work directory and its |
…ss#623) The key check read the decompressed ramdisk with cpio -it, discarded its errors and counted matches, so an archive cpio couldn't list counted as holding no keys, and the install went on to append the owner's key to it and flash every partition. The listing is now its own step that stops with cpio's reason, before the plan and any write. tests/install-phone-initramfs adds cpio -it to its failing steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
Follows the maintainer's suggestion on #596: the key check still listed the decompressed ramdisk with
cpio -it … 2>/dev/null | grep -c … || true, so an archive that lz4 decodes but cpio can't list was read as holding no SSH keys.Reproduced on main through the bundle's
./install --unsigned, with only fastboot faked. In a bundle whose ramdisk is valid lz4 around a truncated cpio (cpio -itexits 2, "premature end of file"), the install appended the owner's key to the broken archive, showed the plan and flashed every partition.The listing is now its own step with its own message, before the plan and any flash: "cpio couldn't list vendor_kernel_boot.img's ramdisk: <cpio's reason>". With
--quiet, cpio still lists filenames on stdout and suppresses the block-count summary on stderr. On bytes that aren't an archive, GNU cpio 2.15 first prints aMalformed number <raw bytes>line for each offset it tries, hundreds of them, so its stderr goes to a file in the work directory and the message carries its last line, the reason. The key check greps the listing from a here-string withgrep -q, so a ramdisk withoutauthorized_keysstill gets the key, with no|| true. It stays inline, because the bundle shipsinstallalone (L-497).Before, on main (6a9251f): the ramdisk fails
cpio -it, yet./installappends the key and flashes all six partitions. Output trimmed by thegrep -Eshown.After, on this branch (38c7e15): the same truncated-cpio case stops with the new message, and nothing is flashed.
Both bundles come from a local script that builds them as
tests/install-phone-initramfsdoes (the hook'somamobile-boot-imagespacks the images) and copies that revision'stools/install-phonein asinstall. The install runs in a bwrap sandbox with the checkout at/mnt, so it prints no local paths.Regression test (a stand-in, not the reproduction):
tests/install-phone-initramfsaddscpio -itto its failing steps. With main's tool it fails at "refuses a failing cpio -it"; with the newdiereplaced by|| trueit fails there too (L-419). Its byte comparison passes with the install under umask 077, 022 and 002.Device and build
uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpasses (503 ok, 0 not ok)tests/packages: no package touchedversionbumped, and the new version is in the commit subject (no package changed)Co-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1):flash()and its allowlist are unchanged, and the new stop comes before the plantools/phone-smokereportNot applicable: install-phone runs on the laptop (CONTRIBUTING.md §6.5).
Generated with Claude Opus 5.5 in T3 Code Nightly