Skip to content

initramfs: guard UFS_RW partitions on a second LUN (UFS_RW_LUNS) - #530

Merged
derekross merged 2 commits into
derekross:mainfrom
matthewjaybarr-png:enchilada-lun-aware-ufs-rw
Nov 9, 2026
Merged

derekross merged 2 commits into
derekross:mainfrom
matthewjaybarr-png:enchilada-lun-aware-ufs-rw

Conversation

@matthewjaybarr-png

@matthewjaybarr-png matthewjaybarr-png commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What and why

On enchilada, userdata is on sda but boot_b is on LUN sde. The storage guard keeps every LUN but sda read-only at the disk level, so the boot_b in UFS_RW could never be written. This follows the enchilada port (#432) and the note in device/enchilada/NOTES.md that a LUN-aware UFS_RW would come as its own pull request.

This adds an optional descriptor key, UFS_RW_LUNS (disk names sdb to sdz), packed as /etc/omamobile-ufs-rw-luns. The init guards each listed LUN the way it guards sda: whole-disk node removed, disk left writable, only UFS_RW partitions writable.

  • Pixels set no key and pack no file, so nothing changes for them.
  • No descriptor sets it yet. enchilada's UFS_RW_LUNS=sde comes with the pull request that teaches push to find boot_b on sde, with the slot-B install and its §3.1 entry.
  • It fails closed: a malformed list or a closed allowlist leaves every LUN but sda read-only.
  • omamobile refuses a bad value at pack time.
  • dodge has the same split and could opt in later. That's its owner's call, so this doesn't touch it.
  • omamobile-boot-update and the installer still look only on sda. enchilada's push and install refuse android-v0 anyway.

Device and build

  • Phone: OnePlus 6 (enchilada), RAM-only fastboot boot from slot A's fastboot; nothing flashed. Pixels are unchanged.
  • Kernel release (uname -r): 7.1.0-rc1-sdm845
  • Packages changed, with versions: none (initramfs/init, bin/omamobile, docs, tests, and the 11-08 boot in enchilada's NOTES)

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes (tests/storage-guard has new cases, on a test descriptor with enchilada's layout and UFS_RW_LUNS=sde, for the list, no list, five malformed lists, a closed allowlist and the pack-time refusals)
  • tests/packages: CI's every-package job (no package changed; locally the omamobile-omarchy series does not apply to Omarchy 4.5.0-3, which this pull request does not touch)
  • Each changed package has its version bumped: no package changed
  • Commits have area prefixes and bodies that say why; AI help is a Co-Authored-By: trailer

On the phone

  • I ran this on my own phone, booted into this build (RAM only, 2026-11-08: commit 2331a85 with UFS_RW_LUNS=sde in the descriptor; recorded in enchilada's NOTES)
  • Guard result, from dmesg and sysfs:
    • allowlist: boot_b userdata, LUNs with allowlisted partitions: sda sde
    • /dev/sda and /dev/sde: whole-disk node removed, disk ro 0
    • writable: only sda17 (userdata) and sde39 (boot_b); the other 71 sde partitions are ro 1
    • sdb, sdc, sdd, sdf: disk ro 1, no writable partition
    • no UFS or I/O errors
  • What I did not test: tools/phone-smoke (this build stays in the initramfs, so there is no session or root to check), and any write to boot_b; nothing writes it yet.
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1). No descriptor sets the new key in this pull request, so it makes no partition writable on any phone.

🤖 Generated with Claude Code

On the OnePlus 6, userdata is on sda but boot_b sits on LUN sde,
which the guard keeps read-only at the disk level, so the boot_b
named in UFS_RW could never be written.

A new optional descriptor key, UFS_RW_LUNS, names the LUNs besides
sda that hold UFS_RW partitions (sdb to sdz). omamobile checks it and
packs it as /etc/omamobile-ufs-rw-luns. The init guards each listed
LUN as it guards sda: whole-disk node removed, disk left writable,
only allowlisted partitions writable. A malformed list, or a closed
allowlist, leaves every LUN but sda read-only.

Pixels set no key and pack no file, so they are unchanged.
enchilada sets UFS_RW_LUNS=sde. tests/storage-guard covers both,
the refusals at pack time and the malformed lists at boot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, Matt. This is careful work on the most sensitive file we have. The new list fails closed at every step I could think of: a missing or broken allowlist, a malformed LUN list, sda or a partition named in it, glob and shell characters. Every Pixel packs no LUN file, so for them the guard runs the same tests as before. The read-only map in your description (sda17 and sde39 writable, the other 71 sde partitions ro 1, sdb-sdd and sdf read-only at the disk level) is exactly the evidence I'd have asked for.

Two things before it merges:

  1. Nothing writes boot_b on sde yet. flash and push refuse android-v0, push looks for slot B's images on sda only, and omamobile-boot-update does too, as your RELEASES row says. A fastboot install never runs the initramfs guard at all. So with UFS_RW_LUNS=sde set today, sde loses its disk-level read-only flag, and the only thing that could use that is a hand dd, which we don't allow. I'd like to take the mechanism now, without enchilada's opt-in: please move UFS_RW_LUNS=sde, and the enchilada wording in NOTES, DEVICES and RELEASES, into the pull request that teaches push to find boot_b on sde, alongside the slot-B install and its §3.1 entry. The enchilada cases in tests/storage-guard can use a test descriptor the way the "six" one is built, so the coverage stays.
  2. Please record the 11-08 boot in the NOTES. The NOTES still say "no boot has run with it yet", but your description reports one. A short dated entry with the lines from your description, the kernel (7.1.0-rc1-sdm845), fastboot boot, and the commit whose initramfs you booted would make it part of the record.

For the record, this conflicts with my own #484 (every LUN guarded like sda). Whichever lands second takes a small resolution: the allowlist checks use your ufs_rw_disk instead of = sda. I'll do that on my side if yours goes first. No Pixel 7 Pro run is needed before merge. I'll check the guard's log lines on my next routine push from main.

Review asked for the enchilada opt-in to land with the change that
teaches push to find boot_b on sde, the slot-B install and its
CONTRIBUTING.md §3.1 entry. This drops UFS_RW_LUNS=sde from its
descriptor and the enchilada wording from DEVICES and RELEASES; the
mechanism and its docs stay.

tests/storage-guard now builds a "lun" test descriptor from enchilada's
with UFS_RW_LUNS=sde, as it builds "six", so the second-LUN cases keep
their coverage.

device/enchilada/NOTES.md records the 11-08 RAM-only boot of 2331a85's
initramfs on 7.1.0-rc1-sdm845.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthewjaybarr-png

Copy link
Copy Markdown
Contributor Author

Thanks. Done in 86286cd:

  • UFS_RW_LUNS=sde and the enchilada wording in DEVICES and RELEASES are out. They'll come with the push change, the slot-B install and its §3.1 entry.
  • tests/storage-guard now builds a lun test descriptor from enchilada's with UFS_RW_LUNS=sde, the same way it builds six. The second-LUN cases are unchanged.
  • enchilada's NOTES has a dated 11-08 entry: fastboot boot of 2331a85's initramfs on 7.1.0-rc1-sdm845, with the guard's result lines.

tests/storage-guard, tests/all and tools/pr-check origin/main pass. I've updated the description to match.

Thanks for taking the #484 conflict on your side.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Matt. This is exactly what I asked for. The LUN-aware guard goes in now, and enchilada's UFS_RW_LUNS=sde waits for the pull request that gives boot_b on sde a real writer (push and the slot-B install finding it there, with its §3.1 entry). That's how I want it: the mechanism lands inert, and the opt-in arrives with the tool that uses it. The lun test descriptor keeps all the second-LUN coverage, and the 11-08 entry in the NOTES is the record I wanted.

I ran tests/storage-guard on your head. All cases pass. As an extra check, I widened the loaded LUN list by one disk, and the lun cases fail as they should. initramfs/init and bin/omamobile are unchanged since my last look, and no descriptor in the tree sets the key, so every phone's guard behaves as before.

Two wording nits. Neither holds the merge, and I'm happy to fix them myself at merge if you'd rather:

  • Once this lands, the LUN-aware guard exists, so the enchilada NOTES line "a LUN-aware UFS_RW will be its own shared pull request" and the DEVICES row's "a LUN-aware UFS_RW follows in its own pull request" should say instead that enchilada's UFS_RW_LUNS=sde comes with the slot-B install.
  • The 11-08 entry names 7.1.0-rc1-sdm845, and your NOTES header describes two builds of that release. Which one was it, first-light or netfilter?

As I said, I'll take the conflict with my #484 on my side. On the 7 Pro I'll read the guard's log lines on my next routine push from main. Thanks again for careful work on the file that protects everyone's calibration data.

@derekross
derekross merged commit 02b9fdb into derekross:main Nov 9, 2026
2 checks passed
@derekross

Copy link
Copy Markdown
Owner

Merged. I've opened the follow-up for the first wording point myself. The second is still a question for you, @matthewjaybarr-png: which 7.1.0-rc1-sdm845 build booted on 11-08, first-light or netfilter? A one-line follow-up to the enchilada NOTES whenever it suits you.

derekross added a commit that referenced this pull request Nov 9, 2026
…s with the slot-B install (#580)

#530 merged the guard's UFS_RW_LUNS without enchilada's opt-in, so the
NOTES and the DEVICES row no longer call it a pull request to come: they
say enchilada's UFS_RW_LUNS=sde arrives with the slot-B install that
gives boot_b on sde a writer.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@matthewjaybarr-png

Copy link
Copy Markdown
Contributor Author

Thanks, Derek. It was the first-light build. The one-line NOTES follow-up is #588.

matthewjaybarr-png added a commit to matthewjaybarr-png/omarchy-mobile that referenced this pull request Nov 10, 2026
… sets sde

push looked for <image>_b only under /sys/block/sda. It now looks on sda
and 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.
enchilada opts in with UFS_RW_LUNS=sde, where its boot_b is (derekross#530's
review). push and flash still refuse android-v0 until the slot-B install
and its CONTRIBUTING §3.1 entry land in this pull request.

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>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ekross#530)

The storage guard takes a list of LUNs whose UFS_RW partitions may be writable (UFS_RW_LUNS, default sda alone), so a device whose boot partitions sit on a second LUN can open them partition by partition while that disk stays read-only. It fails closed on a missing or malformed list, sda or a partition name in it, and glob or shell characters. No descriptor sets the key: enchilada's UFS_RW_LUNS=sde comes with the pull request that gives boot_b on sde a writer (push and the slot-B install, with its CONTRIBUTING section 3.1 entry). tests/storage-guard covers the second LUN with a test descriptor. Every Pixel's guard runs the same tests as before.
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…s with the slot-B install (derekross#580)

derekross#530 merged the guard's UFS_RW_LUNS without enchilada's opt-in, so the
NOTES and the DEVICES row no longer call it a pull request to come: they
say enchilada's UFS_RW_LUNS=sde arrives with the slot-B install that
gives boot_b on sde a writer.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
derekross pushed a commit that referenced this pull request Nov 18, 2026
…and the NFS root

Main gained two things in the guard since this branch: a LUN list beside sda (UFS_RW_LUNS, #530) and the NFS-root mode. Both are kept, on this branch's rule that every LUN loses its whole-disk node and keeps its disk flag clear.

initramfs/init: every LUN is guarded alike; the allowlist is honoured on sda and on a listed LUN only; with an NFS root sda keeps main's disk-level read-only flag and the other LUNs are guarded by their partitions' own flags. tests/storage-guard keeps both sides' cases on the own-flag model (the late LUN is now sdf, since sde is the listed LUN's fixture). akita and oriole get the storage rule's new comment. Versions: device-cheetah 0.1.55, device-lynx 0.2.5, device-raven 0.1.37.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants