Skip to content

apple: follow Aura's enforce policy: fixed boot path, verified EFI only - #77

Closed
DjDeveloperr wants to merge 1 commit into
mainfrom
fix/enforcing-boot
Closed

DjDeveloperr wants to merge 1 commit into
mainfrom
fix/enforcing-boot

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: U-Boot follows Aura's enforce policy. When /chosen/aurora,boot-security shows an enforcing stage, U-Boot:

  • does not read or write uboot.env;
  • gives no console (no boot delay, Ctrl-C ignored, empty preboot);
  • boots only EFI/BOOT/BOOTAA64.EFI from the internal ESP through bootefi under UEFI Secure Boot, and resets otherwise.

The keys come only from a variable seed built into U-Boot. apple_m1_defconfig ships it empty, in a fixed 16 KiB region with an end marker that aurora-secboot fills before it signs Stage 2. Without an enforcing stage, the boot is unchanged.

Tested: no hardware run yet. apple_m1 and apple_j873 build with WERROR. tools/aurora_uefi_seed.py finds exactly one valid empty seed region in the apple_m1 image; CI runs that check, and an image without the region fails it.

Risk: two-way · every Mac booting this U-Boot. Without an enforcing stage the seed has no PK and Secure Boot stays off. The UEFI variables SecureBoot=0 and SetupMode=1 are now reported, where before Secure Boot support was absent.

Not yet:

  • a hardware row on the M3 Pro (J516s, T6030), with an enforcing Stage 2 and test keys:
    • (a) a signed UKI boots, and U-Boot's measurement is in the record;
    • (b) the stock, unsigned BOOTAA64.EFI is refused;
    • (c) a uboot.env that would change the boot is ignored, and the same file is applied without enforce;
    • (e) a seed without keys is refused;
    • (f) a non-enforcing boot is unchanged.
  • (d), a key press during the boot delay, is covered by the code and the environment values only (bootdelay=-2, Ctrl-C off, empty preboot): no host input reaches U-Boot on that rig.
  • The M4 (T8132) and M5 Pro (T6050) are not supported by this U-Boot at all (build_mem_map() panics there), so they have no row.
Details
  • Enforcing means the record's own policy is enforce, or any measurement@N has policy = "enforce", or state is verified. Without the node, nothing changes.
  • Environment:
    • env_get_location() gives only ENV_IS_NOWHERE under enforce, so the built-in environment is imported and saveenv has nowhere to write.
    • Otherwise it gives the FAT location as before and hides the new nowhere location, so a failed load does not fall back to it and saveenv still creates uboot.env.
    • Init stays successful in both cases (no -ENODEV from env_init).
  • Boot: bootcmd is run aurora_secure_boot; reset, with bootdelay=-2, preboot empty and disable_ctrlc(1).
    • aurora_secure_boot loads BOOTAA64.EFI, records its size for the measurement, then runs bootefi with the control FDT.
    • Any failure or return prints AURORA_UBOOT_SECURE_FAIL and resets.
    • There is no booti, bootflow, script, USB or fallback.
    • With no PK in the seed (apple_seed_has_pk() walks the built-in efi_var_file, bounds-checked), bootcmd only reports and resets.
  • Keys: ubootefi.var never restores PK, KEK, db, dbx, dbt, dbr, AuditMode or DeployedMode (efi_var_restore(..., false)), so only the seed sets them. With PRESEED they are also write-protected.
  • Measurement: ft_board_setup() runs from efi_install_fdt() before efi_run_image(). It adds measurement@N (reg, stage u-boot, policy enforce, component EFI/BOOT/BOOTAA64.EFI, verdict verified, sha256) in aura's entry format. The image only starts, and so only sees the record, when Secure Boot verified it.
  • lib/efi_loader/Makefile: -I$(srctree) for efi_var_seed.o, so a relative seed path works with O=, as Kconfig documents. Fedora builds with O=build-aurora.
  • apple_j873 has no seed or Secure Boot. Under enforce it refuses; the measurement code is built only with EFI_SECURE_BOOT.
Evidence
$ make O=b apple_m1_defconfig && scripts/config --file b/.config --enable WERROR && make O=b olddefconfig && make O=b
$ python3 tools/aurora_uefi_seed.py b/u-boot-nodtb.bin
b/u-boot-nodtb.bin: seed region at 0x81530, 16384 bytes, 0 bytes of variables
$ python3 tools/aurora_uefi_seed.py <apple_j873 build>/u-boot-nodtb.bin
...: 0 seed regions, expected exactly one        (exit 1)

apple_j873 also builds with WERROR. The local builds turn off TOOLS_KWBIMAGE/TOOLS_LIBCRYPTO, because this host's OpenSSL 4.1 has no ENGINE API; that is unrelated to this change and also fails on main. CI uses Ubuntu's OpenSSL.

aura records what each boot stage checked in /chosen/aurora,boot-security
of the devicetree it passes to U-Boot. When a stage enforced, aura's
signature covers U-Boot, but nothing U-Boot then reads from the ESP:
the saved uboot.env could replace the boot commands, the console could
be reached during the boot delay, and the T8140 path fell back to booti
and bootflow, none of which checks the image it starts.

When the record shows an enforcing stage (policy "enforce" on the node
or on a measurement, or state "verified"):

- the environment is the built-in one: env_get_location() offers only
  ENV_IS_NOWHERE, so uboot.env is neither read nor written. Without an
  enforcing stage the ESP environment works as before, and the nowhere
  location is not added as a fallback;
- the boot starts at once with no key check (bootdelay -2), Ctrl-C is
  ignored and preboot is empty;
- the only boot is EFI/BOOT/BOOTAA64.EFI on the internal ESP through
  bootefi under UEFI Secure Boot; on failure or return U-Boot resets;
- the Secure Boot keys come only from the variable seed built into
  U-Boot (CONFIG_EFI_VARIABLES_PRESEED; ubootefi.var never restores
  PK, KEK, db, dbx or the mode variables). board/apple/mac/uefi-seed.bin
  is an empty seed in a fixed 16 KiB region that ends in the marker
  AURORA-UEFI-SEED, for aurora-secboot to fill with the owner's keys
  before it signs Stage 2. With no PK in the seed, U-Boot refuses and
  resets;
- U-Boot adds a measurement@N entry to the record for the EFI
  application it hands over (stage u-boot, its SHA-256).

apple_m1_defconfig enables EFI_SECURE_BOOT (with FIT and
FIT_SIGNATURE, which it depends on), EFI_VARIABLES_PRESEED with the
empty seed and ENV_IS_NOWHERE. Without an enforcing stage the seed has
no PK, Secure Boot stays off and the boot is unchanged.

A relative CONFIG_EFI_VAR_SEED_FILE is documented as relative to the
source tree, but .incbin only found it in the build directory, so O=
builds failed; the source tree is now on that object's include path.

tools/aurora_uefi_seed.py checks that an image holds exactly one valid
seed region; CI runs it on the apple_m1 build. doc/board/apple/m1.rst
describes the policy.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team and RyanTheTide as code owners November 26, 2026 10:30
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 9ca692b8: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 9ca692b8, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · every Mac booting this U-Boot. Without an enforcing stage the seed has no PK and Secure Boot stays off. The UEFI variables SecureBoot=0 and SetupMode=1 are now reported, where before Secure Boot support was absent.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Replaced by #78: the shipped U-Boot is built from aurora-wip, which already measures loaded EFI images, and this main-based change resets before Linux on T6030.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant