Repository navigation
stage-boot-files: refuse an initramfs with a development boot policy - #831
Conversation
tools/stage-boot-files copies KERNEL_OUT's initramfs into the device package's boot files, which omamobile-boot-update builds slot B's images from. It refused an initramfs with the builder's SSH keys, dropbear host keys, another device's allowlist or another tree's init, but not one with the development boot policies that `bin/omamobile initramfs --release` refuses to build: OMAMOBILE_NFSROOT, INITRAMFS_ROOT_MODE and INITRAMFS_USB_RECOVERY=no. Staging a development initramfs that was already built, instead of building one with --release, put it in the device package. At the three policy paths it now takes only what --release packs, matching member names as the archive's listing gives them (etc/x or ./etc/x), as its SSH-key check does: no member named etc/omamobile-nfsroot or etc/omamobile-root-mode, whatever its type, and at most one etc/omamobile-usb-recovery, which must read exactly yes; a read that fails stops the tool. Anything else is refused before DEST or DEST.new is touched, saying to build it with --release, so a symlink, a directory or a repeated member under these names is refused too, without unpacking the archive. It does not model what the kernel unpacks: another spelling of the same path (etc//x, etc/./x) or an etc packed as a symlink to another directory is not caught, as the SSH-key check does not catch root//.ssh/authorized_keys. bin/omamobile initramfs writes each policy file once, as a regular file at etc/<name>, which is what this catches. One file the init ignores is refused as well: an empty etc/omamobile-nfsroot. --release never packs that file (the builder removes it in every build without OMAMOBILE_NFSROOT), so nothing --release builds is refused; INITRAMFS_ROOT_LABEL and INITRAMFS_USB_RECOVERY=yes still stage. The maintainer suggested the NFS root guard on derekross#503; the root mode and USB recovery keys came after it (derekross#562), each with its own --release refusal beside the NFS one. Tested: new tests/stage-boot-files cases (cheetah's allowlist and this tree's init in every archive, GNU cpio's and bsdcpio's spellings, an earlier DEST kept; besides each policy as the builder writes it, the NFS file empty, as a symlink and as a directory, and the USB recovery file as a symlink to no, packed twice, saying yes and then appended as a symlink to no (GNU cpio only), and read through a stand-in cpio that prints yes and fails) fail on main's tool and pass here; dropping or weakening each check fails them. The real tool on main 6c11752 staged four development archives built from this tree's init, the files `bin/omamobile initramfs-config` writes and initramfs_pack, with the real dtc and AOSP's pinned mkdtboimg.py; with this change it refuses them and keeps the earlier staging. tools/pr-check origin/main, tests/all and tests/boot-update-parity with AOSP's scripts pass. Not tested: a full `bin/omamobile initramfs` build (it needs Alpine's minirootfs), and anything on a phone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you, Victor, this is a careful one. I checked the three paths against what I also liked that The tool isn't one of the boot files' tracked sources, so this needs no restage and no device-package version. It only adds refusals before anything is written, so release phones get the same images. One optional thing: |
What and why
On main 6c11752,
tools/stage-boot-filesstages an initramfs thatbin/omamobile initramfs --releaserefuses to build: one with an NFS root (OMAMOBILE_NFSROOT), a root mode (INITRAMFS_ROOT_MODE) or USB recovery off (INITRAMFS_USB_RECOVERY=no). A development initramfs staged in place of a--releaseone goes into the device package.I followed the NFS suggestion on #503: "a cheap second guard behind
--release". #562 later added the root mode and USB recovery keys, each with its own--releaserefusal beside the NFS one, so this PR covers all three.The tool now takes only what
--releasepacks, by listed member name (etc/xor./etc/x): noetc/omamobile-nfsrootoretc/omamobile-root-mode, and at most oneetc/omamobile-usb-recovery, saying exactlyyes. Anything else is refused before DEST orDEST.newchanges, saying to build it with--release. What--releasebuilds still stages,INITRAMFS_ROOT_LABELandINITRAMFS_USB_RECOVERY=yesincluded. An emptyetc/omamobile-nfsroot(the init ignores it) is refused:--releasenever packs it.AI agents made every run below. Reproduction, both runs in the block: the real tool for cheetah, real
dtcand AOSP's pinnedmkdtboimg.py, on archives packed from this tree's init and the filesbin/omamobile initramfs-configwrites, in place of a full build (Alpine's minirootfs, which the tool never reads). Main 6c11752 stages four development archives; bf8745b refuses them.Regression test (a stand-in, not the reproduction): new
tests/stage-boot-filescases on archives with cheetah's allowlist and this tree's init. Each policy is refused with its message, DEST kept, also as an empty, symlinked or directory NFS file and a symlinked, repeated or unreadable USB one; release archives stage; both spellings. They fail on main's tool, as does dropping or weakening any one check.Device and build
uname -r): no phoneChecks (no phone needed)
tools/pr-check origin/mainpasses (AI agent)tests/allpasses (AI agent)tests/packagespasses (or the packages I touched: none, so not run)versionbumped, and the new version is in the commit subject: no package changedCo-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
bin/omamobile initramfsbuild; a device package built from the staged files; anything on a phoneuserdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)tools/phone-smokereportNot applicable: a laptop tool that never runs on a phone (CONTRIBUTING.md §6.5).
AI agents made every run in this description, on an x86_64 desktop running Ubuntu 26.04. The tests and checks ran on bf8745b:
tools/pr-check origin/main,tests/all, andtests/stage-boot-filesandtests/boot-update-parityalso with AOSP's pinned scripts inSRC_DIR. Each transcript below names its own commit.Setup: Ubuntu 26.04 on x86_64, GNU cpio 2.15, lz4 1.10.0, dtc 1.7.2, AOSP's
mkdtboimg.pyastools/toolchain.lockpins it; a freshgit archiveof each commit at/mnt/repoin a bwrap sandbox with no network, with fresh archives and DEST under/mnt/run.The driver strips only the colour codes of
bin/omamobile'serror:lines; nothing else is edited.Steps: build six archives (this tree's init,
bin/omamobile initramfs-configfor a made-upsampledevice with cheetah's descriptor and the case's keys,initramfs_pack) →bin/omamobile initramfs --releasefor each development case →tools/stage-boot-filesfor cheetah on each archive in turn, into one DEST →cmpDEST's initramfs with the archive,ls -dDEST.newBefore, on main 6c11752a:
After, on bf8745bb:
Links: the regression test,
tests/stage-boot-filesat bf8745b; the suggestion on #503. The driver that builds the archives and runs the tools is not published; the reproduction paragraph above says what it does.Not shown:
bin/omamobile initramfsbuild (Alpine's minirootfs and packages); the archives above stand in for it.etc//x) or anetcpacked as a symlink is not normalised, on main or here.tests/allin CI's Arch Linux image, wherebsdcpiogives the./etc/xcases (CI runs it).Generated with Claude Opus 5.5 in T3 Code Nightly