diff --git a/.github/workflows/sep-source.yml b/.github/workflows/sep-source.yml index a729a476fd00..eb2aa91e832e 100644 --- a/.github/workflows/sep-source.yml +++ b/.github/workflows/sep-source.yml @@ -72,6 +72,7 @@ jobs: python3 -m unittest tools/aurora-sep/tests/test_policy_window.py -v python3 -m unittest tools/aurora-sep/tests/test_log_ratelimit.py -v python3 -m unittest discover -s tools/aurora-sep/tests -p test_packaging.py -v + python3 -m unittest discover -s tools/aurora-sep/tests -p test_sep_writes_always_on.py -v rust-build: runs-on: ubuntu-24.04 diff --git a/Documentation/ABI/testing/sysfs-driver-apple-sep b/Documentation/ABI/testing/sysfs-driver-apple-sep index 32d4a16c8cdc..b2d673ca52ef 100644 --- a/Documentation/ABI/testing/sysfs-driver-apple-sep +++ b/Documentation/ABI/testing/sysfs-driver-apple-sep @@ -36,8 +36,9 @@ Description: /dev/sep-bio interface. It does not add a new sensor protocol. OS firmware and system firmware are separate: qualify both. - For an existing bag, select xart_writes=1, provision_keybag=0, - xart_guard=1 and xarm_trace=1. trusted_keys=0 and + For an existing bag, select xart_guard=1 and xarm_trace=1; + xART writes and keybag provisioning are always on, and an + existing bag is kept without a write. trusted_keys=0 and filevault_api=0 omit the optional kernel APIs; both default to 1 to preserve existing deployments. There is no boot_uuid parameter: the OS identity comes from /chosen/apfs-preboot-uuid. @@ -98,14 +99,21 @@ KernelVersion: 7.1 Contact: Chris Kearney Description: (RO) Whether the SEP's writes to the shared xART store reach - the disk. Fixed at probe, when the driver opens the store. + the disk. Set at probe, when the driver opens the store; + complete_attach updates it when it reopens the store, and a + failed writable reopen there sets it to disabled. ======== ============================================= - enabled Writes reach the store (xart_writes=1, and - the store validated for writing). - disabled Writes are refused. Touch ID enrol and verify - are refused too, since the SEP must save - state after each. + enabled Writes reach the store (it validated for + writing). + disabled Writes are refused: the key-store-only + initrd phase before complete_attach + (keystore_only=1, or 2 with the xART + guard), or a failed writable reopen. + Touch ID enrol and verify are refused + too, since the SEP must save state after + each. There is no parameter that turns + writes off. ======== ============================================= What: /sys/bus/platform/devices/.sep/diag/attach @@ -173,12 +181,8 @@ Description: failed Provisioning, reading or loading it failed. ======= ============================================== - With provision_keybag=1, the default, the boot-time bring-up - decides it once the key store is open, and it stays - "unknown" if the key store never opens. With - provision_keybag=0, Touch ID activation decides it when it - reads the keybag, and it stays "unknown" if activation fails - before that point. + The boot-time bring-up decides it once the key store is + open, and it stays "unknown" if the key store never opens. What: /sys/bus/platform/devices/.sep/diag/sensor Date: October 2026 @@ -227,15 +231,10 @@ Description: the next boot. ========= ============================================ - "failed" can be intentional. With provision_keybag=0, as on - a read-only install (xart_writes=0, provision_keybag=0), the - bring-up still publishes /dev/sep-bio when no identity - keybag exists yet, and its first open then fails activation - because there is none: keybag reads "missing" and touchid - reads "failed". Read touchid "failed" together with keybag - "missing" (and, on a read-only install, xart "disabled") as - not provisioned rather than broken. Every other way to reach - "failed" is a real failure. + There is no read-only install: the xart_writes and + provision_keybag parameters were removed, so the bring-up + always provisions a missing identity keybag before it + publishes /dev/sep-bio, and "failed" is a real failure. Because the first open of /dev/sep-bio activates Touch ID, a tool waiting for "ready" has to open it, or let its client @@ -388,8 +387,8 @@ Contact: Aurora Silicon maintainers Description: Write-only, root-only (0200). Writing 1 completes an attach started with apple_sep.keystore_only=1: opens host state and - the identity index on the real root, reopens xART with the - configured write and guard policy, and publishes the biometric + the identity index on the real root, reopens xART writable + with the guard policy, and publishes the biometric devices. Sensor activation still occurs on first device open, just as with a normal attach. No SEP registration is repeated. Successful completion is idempotent. Failed store opens may @@ -397,9 +396,10 @@ Description: was loaded without keystore_only. The read-only module parameter retains its load-time value after completion. - In keystore-only mode, xART is read-only regardless of - xart_writes, provisioning is disabled, and no host-state or - guard files are opened for writing. The initrd must carry the + With keystore_only=1, xART is read-only until + complete_attach (keystore_only=2 below), provisioning waits + for it, and no host-state or guard files are opened for + writing. The initrd must carry the existing identity keybag and machine ref-key at their usual /var/lib paths; both are cached on first trusted-key use. An unseal needing an xART write fails with EBADMSG so userspace @@ -410,7 +410,7 @@ Description: only the state, import, unlock, lock and FDE unseal requests; every other request returns EAGAIN until complete_attach. Loading and unlocking a bag needs enclave writes to xART, so - in this mode xART follows xart_writes, but only when the xART + in this mode xART is writable, but only when the xART guard is off (its record list lives in host files on the real root). With a guard, xART stays read-only, the bag requests fail with EROFS and the volume falls back to its passphrase. @@ -422,7 +422,9 @@ Contact: Satya Benson Description: (RO, ABI 3) A space-separated key=value snapshot of the driver policy selected at probe: xart_writes (effective store - writability), provision_keybag, xart_guard (effective level), + writability), provision_keybag (always 1: the parameter was + removed and the driver always provisions a missing keybag), + xart_guard (effective level), trusted_keys, filevault_api, xarm_trace, refkey_v2 and identity_override (0 or 1). API flags describe the selected policy, not successful registration if that API later fails. diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index a0c18035d216..a9cf80938dc4 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -228,13 +228,13 @@ config APPLE_SEP the iBoot system container, locating its .gl extent through read-only, checksum-validated APFS metadata. It validates the complete store and both root records before registering with SEP. - xART writes are enabled by default, but accepted only when the driver + xART writes are always on, and accepted only when the driver validates the physical extent ownership invariants. Unsupported APFS layouts fail closed. A Linux identity keybag is created automatically when none exists; existing identities and reference keys are retained. - Set xart_writes=0 provision_keybag=0 for read-only operation. - With writes off the driver still attaches, but refuses Touch ID enrol - and verify: the enclave saves anti-replay state after every match. + There is no read-only mode: the xart_writes and provision_keybag + module parameters were removed, and a stale value on the kernel + command line or in modprobe.d is ignored. Say Y here if you have an Apple silicon Mac. diff --git a/drivers/soc/apple/attach.rs b/drivers/soc/apple/attach.rs index fd1632181ab9..d7950ecbb1c7 100644 --- a/drivers/soc/apple/attach.rs +++ b/drivers/soc/apple/attach.rs @@ -73,8 +73,8 @@ pub(crate) fn user_bags_requested() -> bool { /// xART guard keeps its record list in host files on the real root, which /// the initrd must not write. So writes are allowed only for user bags and /// only when no guard runs; with a guard the bags wait for complete_attach. -pub(crate) fn initrd_xart_writes(xart_writes: bool, user_bags: bool, guard: Option) -> bool { - xart_writes && user_bags && guard.is_none() +pub(crate) fn initrd_xart_writes(user_bags: bool, guard: Option) -> bool { + user_bags && guard.is_none() } /// Holds the callback context alive until sysfs has drained all writers. @@ -166,11 +166,10 @@ mod tests { #[test] fn initrd_writes_only_for_user_bags_without_a_guard() { - assert!(initrd_xart_writes(true, true, None)); - assert!(!initrd_xart_writes(false, true, None)); - assert!(!initrd_xart_writes(true, false, None)); - assert!(!initrd_xart_writes(true, true, Some(1))); - assert!(!initrd_xart_writes(true, true, Some(2))); + assert!(initrd_xart_writes(true, None)); + assert!(!initrd_xart_writes(false, None)); + assert!(!initrd_xart_writes(true, Some(1))); + assert!(!initrd_xart_writes(true, Some(2))); } #[test] diff --git a/drivers/soc/apple/diag.rs b/drivers/soc/apple/diag.rs index 98814d4929b2..9260cc09151c 100644 --- a/drivers/soc/apple/diag.rs +++ b/drivers/soc/apple/diag.rs @@ -31,7 +31,6 @@ extern "C" { xart: bool, ) -> c_int; fn sep_diag_set_policy( - provision_keybag: bool, trusted_keys: bool, filevault_api: bool, xarm_trace: bool, @@ -101,7 +100,6 @@ pub(crate) enum Restore { /// Boot-time policy, without identity values or key material. pub(crate) struct Policy { - pub provision_keybag: bool, pub trusted_keys: bool, pub filevault_api: bool, pub xarm_trace: bool, @@ -156,7 +154,6 @@ pub(crate) fn register( // SAFETY: the facts are fixed before the attribute group is published. unsafe { sep_diag_set_policy( - policy.provision_keybag, policy.trusted_keys, policy.filevault_api, policy.xarm_trace, diff --git a/drivers/soc/apple/diag_shim.c b/drivers/soc/apple/diag_shim.c index 00754ef808ca..995abe149b0c 100644 --- a/drivers/soc/apple/diag_shim.c +++ b/drivers/soc/apple/diag_shim.c @@ -71,7 +71,6 @@ static struct { bool cold; bool sepos13; bool xart; - bool provision_keybag; bool trusted_keys; bool filevault_api; bool xarm_trace; @@ -164,7 +163,11 @@ static ssize_t xart_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(xart); -/* Parameter policy is captured at probe; the identity choice is cached later. */ +/* + * Parameter policy is captured at probe; the identity choice is cached later. + * provision_keybag stays in the line for ABI 3 readers: the parameter is gone + * and the driver always provisions (an existing keybag is kept). + */ static ssize_t policy_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -185,20 +188,18 @@ static ssize_t policy_show(struct device *dev, struct device_attribute *attr, break; } return sysfs_emit(buf, - "xart_writes=%u provision_keybag=%u xart_guard=%u " + "xart_writes=%u provision_keybag=1 xart_guard=%u " "trusted_keys=%u filevault_api=%u xarm_trace=%u " "refkey_v2=%u identity_override=%u identity_source=%s\n", - sep_diag.xart, sep_diag.provision_keybag, sep_diag.xart_guard, + sep_diag.xart, sep_diag.xart_guard, sep_diag.trusted_keys, sep_diag.filevault_api, sep_diag.xarm_trace, sep_diag.refkey_v2, sep_diag.identity_override, identity); } static DEVICE_ATTR_RO(policy); -void sep_diag_set_policy(bool provision_keybag, bool trusted_keys, - bool filevault_api, bool xarm_trace, bool refkey_v2, - bool identity_override) +void sep_diag_set_policy(bool trusted_keys, bool filevault_api, + bool xarm_trace, bool refkey_v2, bool identity_override) { - sep_diag.provision_keybag = provision_keybag; sep_diag.trusted_keys = trusted_keys; sep_diag.filevault_api = filevault_api; sep_diag.xarm_trace = xarm_trace; diff --git a/drivers/soc/apple/sbio.rs b/drivers/soc/apple/sbio.rs index 0c3b73394193..df31e5bd51a3 100644 --- a/drivers/soc/apple/sbio.rs +++ b/drivers/soc/apple/sbio.rs @@ -2336,25 +2336,18 @@ impl SepData { } pub(crate) fn finish_keystore_bringup(&self) { - if module_parameters::provision_keybag.value() != 0 { - if module_parameters::xart_writes.value() == 0 { - dev_err_ratelimited!( - self.dev, - "bringup: provision_keybag=1 requires xart_writes=1\n" - ); - return; - } - if !self.sks_provision_identity_keybag() { - dev_err_ratelimited!( - self.dev, - "bringup: identity-keybag provisioning failed; no retry this boot\n" - ); - diag::keybag(diag::Keybag::Failed); - return; - } - // Either one was already persisted or one has just been. - diag::keybag(diag::Keybag::Present); + // Always: an existing identity keybag is kept and nothing is written; + // a missing one is created. + if !self.sks_provision_identity_keybag() { + dev_err_ratelimited!( + self.dev, + "bringup: identity-keybag provisioning failed; no retry this boot\n" + ); + diag::keybag(diag::Keybag::Failed); + return; } + // Either one was already persisted or one has just been. + diag::keybag(diag::Keybag::Present); if let Err(e) = self.register_bio() { dev_err_ratelimited!( self.dev, @@ -5829,7 +5822,8 @@ impl SepData { self.write_lockout_state(arg)?; return bio::ok(); } - // With xART writes off the enclave cannot persist what an enrolment or + // With the xART store read-only (the key-store-only initrd phase, or a + // failed writable reopen) the enclave cannot persist what an enrolment or // a match changes. It saves anti-replay state after every match, and a // refused save has left it unresponsive until reboot. Refuse the // capture instead; attach and the read-only ioctls still work. @@ -5837,7 +5831,7 @@ impl SepData { if !self.capture_refusal_logged().xchg(true, Relaxed) { dev_warn_ratelimited!( self.dev, - "Touch ID: enrol and verify need xart_writes=1; the enclave saves anti-replay state after every match and stops responding when that save is refused\n" + "Touch ID: enrol and verify need a writable xART store, and it is read-only now; the enclave saves anti-replay state after every match and stops responding when that save is refused\n" ); } return Err(EROFS); @@ -5884,12 +5878,12 @@ impl SepData { if handled.delete_identity.is_some() || !handled.delete_identities.is_empty() { // A deletion is made durable by saving the Catacombs, and with - // xART writes off that save would be refused. Refuse before 0x57 + // the xART store read-only that save would be refused. Refuse before 0x57 // rather than report a deletion that the next boot undoes. if !self.xart_writable() { dev_warn_ratelimited!( self.dev, - "Touch ID: deleting a fingerprint needs xart_writes=1; with writes off the deletion would not survive a reboot\n" + "Touch ID: deleting a fingerprint needs a writable xART store, and it is read-only now; the deletion would not survive a reboot\n" ); return Err(EROFS); } diff --git a/drivers/soc/apple/sep.rs b/drivers/soc/apple/sep.rs index 02fcc78b2556..4b92483ef262 100644 --- a/drivers/soc/apple/sep.rs +++ b/drivers/soc/apple/sep.rs @@ -1087,19 +1087,17 @@ impl SepData { let xart_start = module_parameters::xart_start_sector.value(); let xart_guard = xart_guard::level(module_parameters::xart_guard.value(), profile.xart_guard); + // SEP writes are always on. Only the key-store-only initrd phase opens + // the store read-only, until complete_attach reopens it writable. let xart_writes = if keystore_only { - attach::initrd_xart_writes( - module_parameters::xart_writes.value() != 0, - keystore_user_bags, - xart_guard, - ) + attach::initrd_xart_writes(keystore_user_bags, xart_guard) } else { - module_parameters::xart_writes.value() != 0 + true }; if keystore_user_bags && !xart_writes { dev_info_ratelimited!( dev, - "initrd: per-user key bags need xart_writes=1 and no xART guard; they wait for the real root\n" + "initrd: per-user key bags need xART writes, which the xART guard holds back until the real root (its list lives there); they wait for the real root\n" ); } // The qualified 26.6.2 lane uses only the boot-forwarded identity. @@ -2213,7 +2211,7 @@ impl SepData { { dev_warn_ratelimited!( self.dev, - "xART: refused the enclave's write (op 0x{:02x}): writes are disabled (xart_writes=0)\n", + "xART: refused the enclave's write (op 0x{:02x}): the store is open read-only (the key-store-only initrd phase, or a failed writable reopen)\n", req.opcode ); } @@ -3014,11 +3012,6 @@ impl SepData { fn finish_attach(&self) -> Result<()> { self.wait_for_trusted_ready()?; - if module_parameters::provision_keybag.value() != 0 - && module_parameters::xart_writes.value() == 0 - { - return Err(EINVAL); - } // Wait out a cached-keybag consumer before enabling persistent writes. // All opens below resolve against PID 1's current (real) root. @@ -3031,7 +3024,7 @@ impl SepData { *store = None; let reopened = (|| { let mut new = xart_store::Store::open_owner( - module_parameters::xart_writes.value() != 0, + true, module_parameters::xart_start_sector.value(), )?; if new.writes_enabled() { @@ -3052,6 +3045,9 @@ impl SepData { module_parameters::xart_start_sector.value(), ) .ok(); + // diag/xart must not keep reading "enabled" (keystore_only=2 + // without a guard opened the store writable at probe). + diag::xart_state(false, None); return Err(e); } }; @@ -3546,13 +3542,6 @@ impl platform::Driver for SepDriver { _info: Option<&'bound Self::IdInfo>, ) -> impl PinInit, Error> + 'bound { let dev: &device::Device> = pdev.as_ref(); - if !attach::requested() - && module_parameters::provision_keybag.value() != 0 - && module_parameters::xart_writes.value() == 0 - { - dev_err_ratelimited!(dev, "provision_keybag=1 requires xart_writes=1\n"); - return Err(EINVAL); - } let sep_node = dt::DtNode::of_device(dev).ok_or(ENODEV)?; // J700's SEP DART window starts above 4 GiB. Leave the proven masks @@ -3581,7 +3570,6 @@ impl platform::Driver for SepDriver { // from "pending" on. Diagnostics are not worth failing the probe for. let guard = data.with_store(|store| store.guard_state()).flatten(); let policy = diag::Policy { - provision_keybag: module_parameters::provision_keybag.value() != 0, trusted_keys: module_parameters::trusted_keys.value() != 0, filevault_api: module_parameters::filevault_api.value() != 0, xarm_trace: module_parameters::xarm_trace.value() != 0, @@ -3693,18 +3681,10 @@ module! { default: 1, description: "Register the SEP FileVault kernel API; 0 leaves it disabled", }, - xart_writes: u8 { - default: 1, - description: "Allow shared xART writes only if APFS proves a single unsnapshotted .gl extent; set to 0 for read-only operation", - }, xart_start_sector: u64 { default: 0, description: "Expected 512-byte start sector of the APFS .gl extent in the iBoot container. Zero accepts the APFS result; nonzero must match it and cannot override it", }, - provision_keybag: u8 { - default: 1, - description: "Create the Linux identity keybag when none exists; set to 0 to disable first-boot provisioning; requires xart_writes=1", - }, xart_guard: i8 { default: -1, description: "-1: the platform's level, 1 on M2 and M3 Macs and 0 on M1 Macs and the MacBook Neo; 0: off; 1: refuse the enclave's writes and deletes of xART session records this Linux install did not create; 2: also refuse writes to the shared root records", diff --git a/drivers/soc/apple/shim.h b/drivers/soc/apple/shim.h index 938e9b9a529a..0cd4c6b9bd5c 100644 --- a/drivers/soc/apple/shim.h +++ b/drivers/soc/apple/shim.h @@ -218,9 +218,8 @@ struct device; int sep_diag_register(struct device *dev, const char *profile, size_t profile_len, bool cold, bool sepos13, bool xart); -void sep_diag_set_policy(bool provision_keybag, bool trusted_keys, - bool filevault_api, bool xarm_trace, bool refkey_v2, - bool identity_override); +void sep_diag_set_policy(bool trusted_keys, bool filevault_api, + bool xarm_trace, bool refkey_v2, bool identity_override); void sep_diag_set_identity_source(unsigned int source); void sep_diag_set_attach(bool attached); void sep_diag_set_endpoints(unsigned int count); diff --git a/drivers/soc/apple/xart_store.rs b/drivers/soc/apple/xart_store.rs index a07a6f005d44..1a52003a5dd7 100644 --- a/drivers/soc/apple/xart_store.rs +++ b/drivers/soc/apple/xart_store.rs @@ -442,8 +442,9 @@ impl Store { Ok(true) } - /// Whether this store accepts writes: `xart_writes=1` and APFS proved the - /// extent writable. + /// Whether this store accepts writes: it was opened for writing (every + /// open but the key-store-only initrd phase's) and APFS proved the extent + /// writable. pub(crate) fn writes_enabled(&self) -> bool { self.writes_enabled } diff --git a/tools/aurora-sep/DESKTOP-FIXES.md b/tools/aurora-sep/DESKTOP-FIXES.md index fabd91c6a288..243f3de8e2c0 100644 --- a/tools/aurora-sep/DESKTOP-FIXES.md +++ b/tools/aurora-sep/DESKTOP-FIXES.md @@ -1,6 +1,6 @@ The installer leaves desktop packages unchanged unless `--desktop-fixes` is selected. This option requires a release containing a matched desktop manifest. -It can accompany the normal install or `--read-only`. +It accompanies the normal install. The supported Omarchy upgrade is the matching stable `omarchy` and `omarchy-settings` pair, `4.0.4-1` to `4.0.4-2`. The installer checks the diff --git a/tools/aurora-sep/M1-SUPPORT.md b/tools/aurora-sep/M1-SUPPORT.md index 6d3c6fa93985..a414b1522f5c 100644 --- a/tools/aurora-sep/M1-SUPPORT.md +++ b/tools/aurora-sep/M1-SUPPORT.md @@ -57,9 +57,10 @@ not included in the production path. `j414s_persistent_enrol=1` remains available for explicitly testing the owner export/save order on other profiles. T8103 and T6020 no longer need it. -Raw xART writes remain opt-in and subject to the extent ownership checks in -[XART-SAFETY.md](XART-SAFETY.md). The kernel includes no raw private tracing -or experimental dummy-keybag/enrollment protocol switches from the investigation. +Raw xART writes are always on (aurora-silicon/linux#2591) and remain subject +to the extent ownership checks in [XART-SAFETY.md](XART-SAFETY.md). The kernel +includes no raw private tracing or experimental dummy-keybag/enrollment +protocol switches from the investigation. ## Validation boundaries diff --git a/tools/aurora-sep/README.md b/tools/aurora-sep/README.md index 715a91171503..c422501e579b 100644 --- a/tools/aurora-sep/README.md +++ b/tools/aurora-sep/README.md @@ -53,22 +53,25 @@ for example with `systemctl edit aurora-sep.service`: Environment=AURORA_SEP_READY_TIMEOUT=180 ``` -The driver defaults to `xart_writes=1`. It exports no module alias, so udev +SEP writes are always on: xART writes and identity-keybag provisioning have +no switch. The driver's `xart_writes` and `provision_keybag` parameters were +removed (aurora-silicon/linux#2591), and a stale value on the kernel command +line or in modprobe.d is ignored. Kernels from before that change still honour a +`0`, so remove any `xart_writes=0` or `provision_keybag=0` left from an earlier +read-only install. The driver exports no module alias, so udev never loads it on its own: the service above loads it, once the iBoot system container is reachable. Writes are accepted only when the APFS `.gl` extent passes the driver's narrow ownership checks: one physical extent, no snapshots or revert state, and a single extent reference owned by the `.gl` inode. The kernel resolves that extent from checksum-validated APFS metadata; unsupported layouts -fail closed. Set `options apple_sep xart_writes=0 provision_keybag=0` in a -modprobe configuration to retain read-only operation. `provision_keybag=1` -is also the default: first boot creates the Linux identity needed for trusted +fail closed. The first boot creates the Linux identity needed for trusted keys, and later boots recover that identity and its machine reference key. An existing unreadable or invalid identity is not silently replaced. -Enabling writes has been tested on m2 with identity-keybag provisioning, +Writes were first tested on m2 with identity-keybag provisioning, trusted-key seal/unseal, and reboot reload. The raw iBoot container hash did not change in those tests, so an actual xART write was **not** validated. Do not infer that all SEP or Touch ID operations work with a read-only GigaLocker. -Read `XART-SAFETY.md` before enabling writes on another dual-boot machine. +Read `XART-SAFETY.md` before installing on a machine that also runs macOS. For read-only structural diagnostics on Linux, run `sudo python3 apfs-xart-inspect.py /dev/disk/by-partlabel/iBootSystemContainer`. diff --git a/tools/aurora-sep/XART-SAFETY.md b/tools/aurora-sep/XART-SAFETY.md index 362612e0dff7..fe94efb5d880 100644 --- a/tools/aurora-sep/XART-SAFETY.md +++ b/tools/aurora-sep/XART-SAFETY.md @@ -1,15 +1,25 @@ # Shared xART gigalocker safety gate -## Current default +## SEP writes are always on + +xART writes and identity-keybag provisioning are always on. The `apple_sep` +driver has no parameter that turns them off: `xart_writes` and +`provision_keybag` were removed (aurora-silicon/linux#2591), and a stale value +on the kernel command line or in modprobe.d is ignored. The APFS +extent-ownership checks, record validation and write-ordering checks remain +mandatory, and unsupported layouts fail closed. Provisioning creates the Linux +identity keybag if it is missing and keeps an existing one without replacing +it. -`xart_writes=1` is the driver default. The APFS extent-ownership checks, -record validation and write-ordering checks remain mandatory; unsupported -layouts fail closed. `xart_writes=0 provision_keybag=0` explicitly selects -read-only operation. `provision_keybag=1` is the default: create the Linux -identity if missing and recover an existing identity without replacing it. The historical evidence below records the earlier opt-in deployments and does not establish qualification on every supported Mac or APFS layout. +Kernels from before linux#2591 still have both parameters. They default to 1 +there, but a `0` is still honoured. So remove any `xart_writes=0` or +`provision_keybag=0` that an earlier read-only install or an old version of +these docs left in `/etc/modprobe.d/` or on the kernel command line. +`aurora-xart status` names each one. + ## Other OSes' records: `xart_guard` The gigalocker is shared by every OS on the Mac, and nothing in a session @@ -369,14 +379,15 @@ same way; that is untested. ## Earlier deployment policy -The iBoot APFS container and its XART `.gl` file are shared with macOS. The -deployed `m2fix4` kernel remains read-only. The `m2fix5` source has an explicit -`xart_writes=1` opt-in; it accepts writes only when the APFS-resolved extent is -single-owner, unsnapshotted, un-cloned, and all existing records validate. -`xart_start_sector` remains only an assertion against the APFS result. The -opt-in is for the controlled J414s hardware test, not general APFS write -support or a promise that restoring an old raw image reverses SEP anti-replay -state. Do not enable it on other installations without equivalent checks. +The iBoot APFS container and its XART `.gl` file are shared with macOS. At +the time, the deployed `m2fix4` kernel was read-only, and the `m2fix5` source +had an explicit `xart_writes=1` opt-in, a parameter since removed +(aurora-silicon/linux#2591). It accepted writes only when the APFS-resolved +extent was single-owner, unsnapshotted, un-cloned, and all existing records +validated, as the driver still requires. `xart_start_sector` remains only an +assertion against the APFS result. That opt-in was for the controlled J414s +hardware test; it was not general APFS write support or a promise that +restoring an old raw image reverses SEP anti-replay state. ## Evidence collected on 2026-09-21 diff --git a/tools/aurora-sep/aurora-sep b/tools/aurora-sep/aurora-sep index 5f986bbd0f5d..0f30b335f6ef 100755 --- a/tools/aurora-sep/aurora-sep +++ b/tools/aurora-sep/aurora-sep @@ -203,7 +203,7 @@ def status(live=True): if xart == "enabled": r.add(PASS, "xart", xart, "the enclave's state writes reach the disk") else: - r.add(WARN, "xart", xart, "xART writes are off (xart_writes=0): enrol and verify are refused") + r.add(WARN, "xart", xart, "xART writes are disabled: the store is read-only this boot (key-store-only initrd phase, a failed writable reopen, or a leftover xart_writes setting under a kernel from before linux#2591, which should be removed): enrol and verify are refused") osid = d("os_identity") if osid is not None: diff --git a/tools/aurora-sep/aurora-sep-ready b/tools/aurora-sep/aurora-sep-ready index e12c6373a728..d1043c26e299 100644 --- a/tools/aurora-sep/aurora-sep-ready +++ b/tools/aurora-sep/aurora-sep-ready @@ -140,7 +140,7 @@ blocked_reason() { optout="To match anyway, set 'options apple_sep xart_guard=0' in /etc/modprobe.d/ and reboot; the enclave may then rewrite session records another OS on this Mac (macOS) created, see XART-SAFETY.md" refusals=$(attr xart_guard_refusals) if [ "$(attr xart)" = disabled ]; then - echo "xART writes are disabled (xart_writes=0, or the gigalocker did not validate for writing), and a match must save state there" + echo "xART writes are disabled (the store is read-only this boot, or a leftover xart_writes setting under a kernel from before linux#2591), and a match must save state there" elif [ "$refusals" != absent ] && [ "$refusals" != 0 ]; then echo "the xART guard (level $(attr xart_guard)) refused $refusals write(s) of records this Linux install did not create. $optout" elif [ "$(attr xart_guard_list)" = unavailable ]; then diff --git a/tools/aurora-sep/install-aurora-sep.sh b/tools/aurora-sep/install-aurora-sep.sh index d5bb35891a53..b27cad73b1ae 100755 --- a/tools/aurora-sep/install-aurora-sep.sh +++ b/tools/aurora-sep/install-aurora-sep.sh @@ -2,7 +2,6 @@ # Install the aurora custom/sep kernel and Touch ID on an Omarchy Mac. # # curl -fsSL https://github.com/omacom/linux-aurora/releases/latest/download/install-aurora-sep.sh | bash -# ... | bash -s -- --read-only install, but never let the driver write to the enclave # ... | bash -s -- --uninstall go back to the kernel this Mac had before # ... | bash -s -- --reset-touchid start Touch ID over: new keybag, enrol again # ... | bash -s -- --m3-report M3: write a bring-up report to attach to an issue (read-only) @@ -203,6 +202,10 @@ # waiting for a finger at lid close can't leave the sensor claimed), and # this Mac's own sensor calibration. After the reboot, run # aurora-touchid-setup to enrol a finger and use it for sudo and the lock screen. +# SEP writes are always on: the driver provisions its identity keybag and writes +# to the enclave's anti-replay store (xART) on the first boot. --read-only was +# removed (aurora-silicon/linux#2591), and an install deletes the file an +# earlier --read-only install left in /etc/modprobe.d. # # m1n1: one m1n1-aurora (M1N1_PACKAGE) for every Mac. It builds # AsahiLinux/m1n1 main (3e354a24), which knows the macOS 26.5 to 27.0 firmware @@ -297,9 +300,13 @@ PIN_BEGIN="# >>> aurora-sep pin (remove with: install-aurora-sep.sh --uninstall) PIN_END="# <<< aurora-sep pin" STATE=/var/lib/aurora-sep FALLBACK_ID=aurora-sep-previous-kernel -# Written only by --read-only; keeps the driver from writing to the enclave. +# Written only by --read-only, which was removed: SEP writes are always on +# (aurora-silicon/linux#2591). An install deletes the file that option wrote +# (read_only_conf_cleanup), as --uninstall does; any other file there is the owner's. MODPROBE_CONF=/etc/modprobe.d/aurora-sep.conf -READ_ONLY=0 +# What --read-only wrote there: this first line, comments and the options line. +READ_ONLY_CONF_HEADER="# aurora-sep --read-only:" +READ_ONLY_CONF_OPTIONS="options apple_sep xart_writes=0 provision_keybag=0" DESKTOP_FIXES=0 DESKTOP_FIXES_DATA="" DESKTOP_FIXES_PACKAGES="" @@ -3643,24 +3650,87 @@ calibration() { warn "could not extract the calibration; Touch ID will not work until it is present at $out" } -# The first line in modprobe.d that blacklists or redirects apple_sep, other -# than our own file. Either spelling is the owner saying "do not load this". +# The modprobe.d directories sep_block_line reads. Tests point it elsewhere +# with AURORA_SEP_TEST_MODPROBE_DIRS; nothing else should set that. +SEP_MODPROBE_DIRS=${AURORA_SEP_TEST_MODPROBE_DIRS:-"/etc/modprobe.d /run/modprobe.d /usr/lib/modprobe.d"} + +# The first line in modprobe.d that blacklists or redirects apple_sep. Either +# spelling is the owner saying "do not load this". $MODPROBE_CONF counts too: +# this script no longer writes it, so whatever is there now is the owner's (the +# file an earlier --read-only install wrote had no such line). sep_block_line() { - local f - for f in /etc/modprobe.d/*.conf /run/modprobe.d/*.conf /usr/lib/modprobe.d/*.conf; do - [[ -f $f && $f != "$MODPROBE_CONF" ]] || continue - grep -m1 -HnE '^[[:space:]]*(blacklist|install)[[:space:]]+apple[-_]sep([[:space:]]|$)' "$f" 2>/dev/null && - return 0 + local d f + for d in $SEP_MODPROBE_DIRS; do + for f in "$d"/*.conf; do + [[ -f $f ]] || continue + grep -m1 -HnE '^[[:space:]]*(blacklist|install)[[:space:]]+apple[-_]sep([[:space:]]|$)' "$f" 2>/dev/null && + return 0 + done done return 0 } -# With its defaults the driver provisions an identity keybag and writes to the -# enclave's anti-replay store (xART) on the first boot of a Mac that has a -# Touch ID profile -- no enrolment needed. That is the intended behaviour, but -# the owner has to be able to opt out, and a block they already set must win. +# Whether FILE is the one an earlier --read-only install wrote: its first line +# is READ_ONLY_CONF_HEADER, and every other line is blank, a comment or +# READ_ONLY_CONF_OPTIONS. Anything else there is the owner's own. +read_only_conf_is_ours() { # FILE + local line first=1 + [[ -f $1 && ! -L $1 && -r $1 ]] || return 1 + while IFS= read -r line || [[ -n $line ]]; do + if ((first)); then + [[ $line == "$READ_ONLY_CONF_HEADER"* ]] || return 1 + first=0 + continue + fi + line=${line#"${line%%[![:space:]]*}"} + line=${line%"${line##*[![:space:]]}"} + [[ -z $line || $line == \#* || $line == "$READ_ONLY_CONF_OPTIONS" ]] || return 1 + done <"$1" + ((!first)) +} + +# --read-only was removed: SEP writes are always on (aurora-silicon/linux#2591). +# The file an earlier --read-only install wrote goes, on an install, a re-run +# and --reset-touchid: on a kernel from before #2591 it still kept the driver +# from writing. Any other file at that path is the owner's and stays. +read_only_conf_cleanup() { + [[ -e $MODPROBE_CONF || -L $MODPROBE_CONF ]] || return 0 + if read_only_conf_is_ours "$MODPROBE_CONF"; then + if $sudo rm -f -- "$MODPROBE_CONF"; then + say "Removed $MODPROBE_CONF, left by an earlier --read-only install: SEP writes are always on (aurora-silicon/linux#2591)" + else + warn "could not remove $MODPROBE_CONF, left by an earlier --read-only install; remove it by hand" + fi + else + warn "$MODPROBE_CONF is not the file an earlier --read-only install wrote, so it stays as it is. + Kernels from aurora-silicon/linux#2591 on ignore xart_writes and provision_keybag + there: SEP writes are always on. Kernels from before it still honour a 0, so remove + any xart_writes=0 or provision_keybag=0 it sets. Its other settings still apply." + fi + return 0 +} + +# Whether the owner's own file at $MODPROBE_CONF still turns writes or keybag +# provisioning off: it sets xart_writes=0 or provision_keybag=0, and the +# installed apple_sep (a kernel from before aurora-silicon/linux#2591) still +# has those parameters. The file an earlier --read-only install wrote does not +# count: read_only_conf_cleanup removes it. +kept_conf_turns_writes_off() { + [[ -f $MODPROBE_CONF ]] || return 1 + read_only_conf_is_ours "$MODPROBE_CONF" && return 1 + grep -qE '^[[:space:]]*options[[:space:]]+apple[-_]sep[[:space:]](.*[[:space:]])?(xart[-_]writes|provision[-_]keybag)=0+([[:space:]]|$)' \ + "$MODPROBE_CONF" 2>/dev/null || return 1 + modinfo -F parm apple_sep 2>/dev/null | grep -qE '^(xart_writes|provision_keybag):' +} + +# The driver provisions an identity keybag and writes to the enclave's +# anti-replay store (xART) on the first boot of a Mac that has a Touch ID +# profile -- no enrolment needed. SEP writes are always on; the driver has no +# switch that turns them off. An owner who does not want the driver loaded at +# all blocks it in modprobe.d, and a block they already set must win. sep_policy() { local block + read_only_conf_cleanup block=$(sep_block_line) if [[ -n $block ]]; then warn "apple_sep is blocked on this Mac ($block). @@ -3670,27 +3740,15 @@ sep_policy() { $sudo systemctl disable apple-sep.path apple-sep.service 2>/dev/null || true return 0 fi - if (( READ_ONLY )); then - printf '%s\n' \ - "# aurora-sep --read-only: the driver attaches and reports, but never writes" \ - "# to the enclave. Delete this file to allow enrolment." \ - "options apple_sep xart_writes=0 provision_keybag=0" | - $sudo tee "$MODPROBE_CONF" >/dev/null - say "Read-only: the SEP driver will attach but not write to the enclave ($MODPROBE_CONF)" - elif [[ -f $MODPROBE_CONF ]]; then - # Re-running to update must never quietly turn writes back on. - say "Still read-only from an earlier --read-only install; delete $MODPROBE_CONF to allow enrolment" - fi $sudo systemctl enable apple-sep.path apple-sep.service } sep_write_notice() { - (( READ_ONLY )) && return 0 - [[ -f $MODPROBE_CONF || -n $(sep_block_line) ]] && return 0 + [[ -n $(sep_block_line) ]] && return 0 warn "on the first boot of a Mac with a Touch ID profile, the SEP driver creates - an identity keybag and writes to the enclave's anti-replay store. Use a Mac - you can DFU-restore. If you cannot, press Ctrl-C now and run with --read-only: - curl -fsSL $LATEST_URL | bash -s -- --read-only" + an identity keybag and writes to the enclave's anti-replay store (xART). + SEP writes are always on. Use a Mac you can DFU-restore; if you cannot, + press Ctrl-C now." return 0 } @@ -4218,7 +4276,6 @@ install_all() { release_source require_supported_soc if ((ESP_ARCHIVE_HISTORY)); then - ((!READ_ONLY)) || die "--archive-esp-history changes the EFI partition and cannot be combined with --read-only" esp_history_run archive fi neo_gpu_plan @@ -4472,9 +4529,6 @@ install_all() { say "Done. Reboot: expect the desktop on the boot framebuffer. Touch ID is not supported on M3 yet. How to help bring this M3 further: step 11 of the test plan that the --agent-prompt command below prints." - elif [[ -f $MODPROBE_CONF ]]; then - say "Done, read-only. Reboot; the SEP driver will attach and report without writing." - echo " Enrolling a finger needs writes: delete $MODPROBE_CONF, reboot, then run aurora-touchid-setup." else say "Done. Reboot, then run: aurora-touchid-setup" fi @@ -4615,7 +4669,8 @@ uninstall_all() { ;; handoff) m3_restore_bringup ;; esac - $sudo rm -f "$MODPROBE_CONF" + # Only the file an earlier --read-only install wrote; an owner's own stays. + read_only_conf_cleanup # Keep recovery state and modules if the checked entry cannot be removed. if [[ $(boot_chain) == limine ]] && m3_limine_cleanup_needed; then m3_limine_remove_check remove @@ -4684,10 +4739,10 @@ reset_touchid() { esac done grep -qa 'apple,' /proc/device-tree/compatible 2>/dev/null || die "this is not an Apple Silicon Mac" - [[ -f $MODPROBE_CONF ]] && - die "this Mac was installed read-only ($MODPROBE_CONF): a new keybag needs enclave writes. Delete that file first if you mean to allow them." for f in "${TOUCHID_STATE_FILES[@]}"; do [[ -e $f ]] && found=1; done ((found)) || die "no Touch ID state on this Mac; nothing to reset" + kept_conf_turns_writes_off && + die "$MODPROBE_CONF sets xart_writes=0 or provision_keybag=0, and this kernel, from before aurora-silicon/linux#2591, still honours it: the next boot could not create a new keybag. Remove that setting first." # Ask for sudo now, in the foreground: a password prompt under timeout # below could not read the terminal. Not sudo -v, which wants a password @@ -4724,6 +4779,15 @@ reset_touchid() { [[ $answer == RESET ]] || die "not reset" fi + # The new keybag needs enclave writes, which a kernel from before + # aurora-silicon/linux#2591 still left off under an earlier --read-only + # install's file. SEP writes are always on: that file goes, and if it cannot + # be removed nothing else is changed (the next boot of such a kernel would + # create no keybag). + read_only_conf_cleanup + read_only_conf_is_ours "$MODPROBE_CONF" && + die "$MODPROBE_CONF, left by an earlier --read-only install, could not be removed; nothing was reset. Remove it and run again." + # Until the reboot nothing may touch the sensor: a match or enrolment would # write new state behind the move. The runtime mask goes away at boot. A # verify already running finishes its save within about a second. @@ -6406,12 +6470,11 @@ was not pinned down. SAFETY, NON-NEGOTIABLE - This touches the Secure Enclave. Confirm the owner can DFU-restore this Mac before you start. - - A default install is NOT read-only. On the first boot of a Mac with a - Touch ID profile, the SEP driver loads automatically, creates an identity - keybag and writes to the enclave's anti-replay store (xART) -- before - anyone enrols a finger. If the owner cannot DFU-restore, install with - --read-only instead, before the first reboot: - curl -fsSL https://github.com/omacom/linux-aurora/releases/latest/download/install-aurora-sep.sh | bash -s -- --read-only + - SEP writes are always on; there is no read-only install. On the first + boot of a Mac with a Touch ID profile, the SEP driver loads automatically, + creates an identity keybag and writes to the enclave's anti-replay store + (xART) -- before anyone enrols a finger. If the owner cannot DFU-restore, + do not install. A 'blacklist apple_sep' line does not prevent this on its own; the installer detects one and leaves the driver off. - Do not run any enrol/delete/re-provision loop unless the owner asks for @@ -10859,11 +10922,12 @@ m3max_kit_runner() { # ACTION # Tests source this file for its functions only. if [[ ${AURORA_SEP_SOURCE_ONLY:-} == 1 ]]; then return 0; fi -# --m3-handoff, --m3-gpu-experiment and --no-m3-mesa go with an install, alone, together or -# with --read-only. +# --m3-handoff, --m3-gpu-experiment and --no-m3-mesa go with an install, alone or together. +# --read-only was removed: SEP writes are always on. args=() for a in "$@"; do case $a in + --read-only) die "--read-only was removed: SEP writes are always on (aurora-silicon/linux#2591)" ;; --archive-esp-history) ESP_ARCHIVE_HISTORY=1 ;; --neo-gpu) NEO_GPU=1 ;; --m3-handoff) M3_TRY=1 ;; @@ -10882,23 +10946,23 @@ set -- "${args[@]}" if ((ESP_ARCHIVE_HISTORY)) && [[ -n ${1:-} ]]; then die "--archive-esp-history goes with an install; use --esp-history for a read-only inventory" fi -if ((NEO_GPU)) && [[ -n ${1:-} && $1 != --read-only ]]; then +if ((NEO_GPU)) && [[ -n ${1:-} ]]; then die "--neo-gpu goes with an install, not with $1" fi if ((M3_GPU_AUTO && M3_GPU_EXPLICIT_PROFILE)); then die "use --m3-gpu by itself to detect the profile, or choose one explicit GPU profile" fi -if ((DESKTOP_FIXES)) && [[ -n ${1:-} && $1 != --read-only ]]; then - die "--desktop-fixes goes with an install (alone or with --read-only), not with $1" +if ((DESKTOP_FIXES)) && [[ -n ${1:-} ]]; then + die "--desktop-fixes goes with an install, not with $1" fi -if ((M3_TRY)) && [[ -n ${1:-} && $1 != --read-only ]]; then - die "--m3-handoff goes with an install (alone or with --read-only), not with $1" +if ((M3_TRY)) && [[ -n ${1:-} ]]; then + die "--m3-handoff goes with an install, not with $1" fi -if ((M3_GPU_EXPERIMENT || M3_GPU_PERSISTENT)) && [[ -n ${1:-} && $1 != --read-only ]]; then - die "M3 GPU options go with an install (alone, with --m3-handoff or with --read-only), not with $1" +if ((M3_GPU_EXPERIMENT || M3_GPU_PERSISTENT)) && [[ -n ${1:-} ]]; then + die "M3 GPU options go with an install (alone or with --m3-handoff), not with $1" fi -if ((!M3_PRO_MESA)) && [[ -n ${1:-} && $1 != --read-only ]]; then - die "--no-m3-mesa goes with an install (alone, with another install option or with --read-only), not with $1" +if ((!M3_PRO_MESA)) && [[ -n ${1:-} ]]; then + die "--no-m3-mesa goes with an install (alone or with another install option), not with $1" fi # One option at a time; these commands take arguments of their own. if (($# > 1)) && [[ $1 != --reset-touchid && $1 != --m3-gpu-check && $1 != --m3max-kit && $1 != --m3max-kit-runner ]]; then @@ -10908,7 +10972,6 @@ fi if preflight_needed "${1:-}"; then preflight; fi case ${1:-} in "") install_all ;; - --read-only) READ_ONLY=1; install_all ;; --uninstall) uninstall_all ;; --reset-touchid) shift; reset_touchid "$@" ;; --esp-history) esp_history_run report ;; @@ -10921,5 +10984,5 @@ case ${1:-} in --m3max-kit-stop) m3max_kit_from_release --stop ;; --m3max-kit-restore) m3max_kit_from_release --restore ;; --agent-prompt) release_source >&2; prompt_notice; agent_prompt ;; - *) die "unknown option $1 (--read-only, --uninstall, --reset-touchid, --agent-prompt, --m3-report, --m3-power-survey, --neo-gpu, --m3-handoff, --m3-gpu, --m3-gpu-check, --m3-gpu-experiment, --m3-gpu-persistent, --m3-profile=j613-25g83, --m3-profile=j615-25g83, --no-m3-mesa, --archive-esp-history, --esp-history, --desktop-fixes, --m3max-kit or --m3max-kit-status, -stop, -restore)" ;; + *) die "unknown option $1 (--uninstall, --reset-touchid, --agent-prompt, --m3-report, --m3-power-survey, --neo-gpu, --m3-handoff, --m3-gpu, --m3-gpu-check, --m3-gpu-experiment, --m3-gpu-persistent, --m3-profile=j613-25g83, --m3-profile=j615-25g83, --no-m3-mesa, --archive-esp-history, --esp-history, --desktop-fixes, --m3max-kit or --m3max-kit-status, -stop, -restore)" ;; esac diff --git a/tools/aurora-sep/load-driver b/tools/aurora-sep/load-driver index 8e45fd451185..481e63af7e85 100755 --- a/tools/aurora-sep/load-driver +++ b/tools/aurora-sep/load-driver @@ -51,7 +51,14 @@ case "$(cat /sys/module/apple_sep/parameters/keystore_only 2>/dev/null || true)" exit 1 fi ;; - *) modprobe apple_sep xart_writes=1 provision_keybag=1 ;; + *) + # No options: SEP writes are always on, so there is nothing to set + # (xart_writes and provision_keybag were removed, + # aurora-silicon/linux#2591). Passing them here also gave each one + # twice next to a stale apple_sep.xart_writes= on the kernel command + # line, and kernels before #2591 then refused to load the driver. + modprobe apple_sep + ;; esac work=$(mktemp -d /run/aurora-sep-load.XXXXXX) diff --git a/tools/aurora-sep/packaging/arch/aurora-sep/PKGBUILD b/tools/aurora-sep/packaging/arch/aurora-sep/PKGBUILD index d0c4a58795d7..b9dc8bc9b331 100644 --- a/tools/aurora-sep/packaging/arch/aurora-sep/PKGBUILD +++ b/tools/aurora-sep/packaging/arch/aurora-sep/PKGBUILD @@ -7,7 +7,7 @@ pkgname=aurora-sep pkgver=1 -pkgrel=17 +pkgrel=18 pkgdesc="Loader and desktop integration for the Apple SEP (Touch ID) driver" url="https://github.com/aurora-silicon/linux/tree/aurora-wip/tools/aurora-sep" arch=(any) diff --git a/tools/aurora-sep/packaging/fedora/aurora-sep.spec b/tools/aurora-sep/packaging/fedora/aurora-sep.spec index 399b8dc4b0b3..7a1ba80b0514 100644 --- a/tools/aurora-sep/packaging/fedora/aurora-sep.spec +++ b/tools/aurora-sep/packaging/fedora/aurora-sep.spec @@ -8,7 +8,7 @@ Name: aurora-sep Version: 1 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Loader and desktop integration for the Apple SEP fingerprint driver License: GPL-2.0-only @@ -197,6 +197,13 @@ fi %ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{modulename} %changelog +* Fri Nov 20 2026 Diljit Singh - 1-13 +- SEP writes are always on: aurora-sep-load runs modprobe apple_sep with no + options, since the driver no longer has xart_writes or provision_keybag + (aurora-silicon/linux#2591); the docs no longer offer a read-only setting +- aurora-sep and aurora-sep-ready name only the fail-closed causes of + disabled xART writes + * Sat Nov 07 2026 Ryan Murray - 1-12 - Take the distribution packages' changes: wait on the driver's key-store attribute before the trusted-key probe, leave /dev/sep-bio to diff --git a/tools/aurora-sep/tests/test_air_gpu.py b/tools/aurora-sep/tests/test_air_gpu.py index 414142be64f1..26cec8567230 100644 --- a/tools/aurora-sep/tests/test_air_gpu.py +++ b/tools/aurora-sep/tests/test_air_gpu.py @@ -1625,13 +1625,13 @@ def test_options(self): SRC.index('if preflight_needed "${1:-}"')] for args, want in [("--m3-gpu-experiment", "ok 0 1 -"), ("--m3-handoff --m3-gpu-experiment", "ok 1 1 -"), - ("--m3-gpu-experiment --read-only", "ok 0 1 --read-only"), + ("--m3-gpu-experiment --read-only", "error: --read-only was removed: SEP writes are always on"), ("--m3-gpu-experiment --uninstall", "error: M3 GPU options go with an install"), ("--m3-report --m3-gpu-experiment", "error: M3 GPU options go with an install"), ("--uninstall", "ok 0 0 --uninstall"), ("--no-m3-mesa", "ok 0 0 - 0"), ("--m3-gpu-experiment --no-m3-mesa", "ok 0 1 - 0"), - ("--no-m3-mesa --read-only", "ok 0 0 --read-only 0"), + ("--no-m3-mesa --read-only", "error: --read-only was removed: SEP writes are always on"), ("--no-m3-mesa --uninstall", "error: --no-m3-mesa goes with an install"), ("--m3-report --no-m3-mesa", "error: --no-m3-mesa goes with an install"), ("", "ok 0 0 - 1")]: diff --git a/tools/aurora-sep/tests/test_desktop_fixes.py b/tools/aurora-sep/tests/test_desktop_fixes.py index 5fada5a7676a..a0693bfba7fa 100644 --- a/tools/aurora-sep/tests/test_desktop_fixes.py +++ b/tools/aurora-sep/tests/test_desktop_fixes.py @@ -158,9 +158,13 @@ def test_actual_argument_parser_requires_install_action(self): source=ROOT/'install-aurora-sep.sh';text=source.read_text() tail=text[text.index('args=()\n',text.index('# Tests source this file')):] shim=self.base/'parser.sh';shim.write_text(f'AURORA_SEP_SOURCE_ONLY=1 source "{source}"\n' - 'preflight() { :; }; install_all() { echo "$DESKTOP_FIXES:$READ_ONLY"; }; uninstall_all() { echo UNINSTALL; };\n'+tail) + 'preflight() { :; }; install_all() { echo "$DESKTOP_FIXES"; }; uninstall_all() { echo UNINSTALL; };\n'+tail) + r=subprocess.run(['bash',str(shim),'--desktop-fixes'],env=self.env,text=True,capture_output=True) + self.assertEqual((r.returncode,r.stdout),(0,'1\n'),r.stderr) + # --read-only was removed (SEP writes are always on): it is refused, and nothing is installed. r=subprocess.run(['bash',str(shim),'--desktop-fixes','--read-only'],env=self.env,text=True,capture_output=True) - self.assertEqual((r.returncode,r.stdout),(0,'1:1\n'),r.stderr) + self.assertNotEqual(r.returncode,0);self.assertEqual(r.stdout,'') + self.assertIn('--read-only was removed: SEP writes are always on',r.stderr) r=subprocess.run(['bash',str(shim),'--desktop-fixes','--uninstall'],env=self.env,text=True,capture_output=True) self.assertNotEqual(r.returncode,0);self.assertNotIn('UNINSTALL',r.stdout) def test_assembler_verifies_optional_three_roles_and_keeps_default_empty(self): diff --git a/tools/aurora-sep/tests/test_diag_policy.py b/tools/aurora-sep/tests/test_diag_policy.py index 27ace56de905..44484b571c53 100644 --- a/tools/aurora-sep/tests/test_diag_policy.py +++ b/tools/aurora-sep/tests/test_diag_policy.py @@ -55,11 +55,11 @@ def test_selected_policy_and_identity_source_only(self): endpoint_limit = re.search(r'^#define SEP_DIAG_MAX_EP\s+\d+', text, re.M).group(0) main = '''int main(void) { char out[4096]; sep_diag.xart = true; sep_diag.xart_guard = 1; - sep_diag_set_policy(false, false, false, true, false, false); + sep_diag_set_policy(false, false, true, false, false); for (unsigned int i = 0; i < 4; i++) { sep_diag_set_identity_source(i); policy_show(NULL, NULL, out); fputs(out, stdout); } - sep_diag_set_policy(true, true, true, false, true, true); + sep_diag_set_policy(true, true, false, true, true); sep_diag.xart = false; sep_diag.xart_guard = 0; policy_show(NULL, NULL, out); fputs(out, stdout); return 0; } @@ -70,7 +70,9 @@ def test_selected_policy_and_identity_source_only(self): subprocess.run([compiler, '-std=gnu11', '-Wall', '-Wextra', '-Werror', '-Wno-unused-parameter', str(source), '-o', str(program)], check=True) lines = subprocess.check_output([str(program)], text=True).splitlines() - expected = dict(xart_writes='1', provision_keybag='0', xart_guard='1', + # provision_keybag has no parameter any more: the driver always + # provisions, and the key stays for ABI 3 readers. + expected = dict(xart_writes='1', provision_keybag='1', xart_guard='1', trusted_keys='0', filevault_api='0', xarm_trace='1', refkey_v2='0', identity_override='0') for line, identity in zip(lines[:4], ('pending', 'dt', 'override', 'missing')): diff --git a/tools/aurora-sep/tests/test_esp_history.py b/tools/aurora-sep/tests/test_esp_history.py index e91fb2e132db..91e39f6da6cd 100644 --- a/tools/aurora-sep/tests/test_esp_history.py +++ b/tools/aurora-sep/tests/test_esp_history.py @@ -197,12 +197,21 @@ def test_install_archives_only_when_requested_before_planning(self): self.assertEqual(run.stdout.splitlines(), (['HISTORY:archive'] if enabled else []) + ['PLAN']) - def test_read_only_install_does_not_archive(self): - run = self.shell('release_source(){ :; }; require_supported_soc(){ :; }; ' - 'esp_history_run(){ echo ARCHIVE; }; ' - 'ESP_ARCHIVE_HISTORY=1; READ_ONLY=1; install_all') + def test_removed_read_only_option_does_not_archive(self): + # --read-only was removed (SEP writes are always on): with --archive-esp-history the + # option parser refuses it before anything runs. + installer = SCRIPT.with_name('install-aurora-sep.sh') + text = installer.read_text() + tail = text[text.index('args=()\n', text.index('# Tests source this file')):] + stubs = ('preflight(){ :; }; esp_history_run(){ echo ARCHIVE; }; ' + 'install_all(){ echo INSTALL; }; ') + run = subprocess.run(['bash', '-c', 'export AURORA_SEP_SOURCE_ONLY=1; source "$1"; shift; ' + + stubs + tail, 'test', str(installer), + '--archive-esp-history', '--read-only'], + capture_output=True, text=True) self.assertNotEqual(run.returncode, 0) - self.assertNotIn('ARCHIVE', run.stdout) + self.assertEqual(run.stdout, '') + self.assertIn('--read-only was removed: SEP writes are always on', run.stderr) if __name__ == '__main__': diff --git a/tools/aurora-sep/tests/test_m3_max.py b/tools/aurora-sep/tests/test_m3_max.py index c242c71a9e20..4f8be786119f 100644 --- a/tools/aurora-sep/tests/test_m3_max.py +++ b/tools/aurora-sep/tests/test_m3_max.py @@ -1267,7 +1267,8 @@ def test_options(self): block = SRC[SRC.index('\nargs=()\nfor a in "$@"; do'):SRC.index('if preflight_needed "${1:-}"')] for args, want in [("--m3-power-survey", "ok --m3-power-survey"), ("--m3-power-survey --m3-handoff", "error: --m3-handoff goes with an install"), - ("--m3-power-survey --read-only", "error: unexpected arguments after --m3-power-survey")]: + ("--m3-power-survey --uninstall", "error: unexpected arguments after --m3-power-survey"), + ("--m3-power-survey --read-only", "error: --read-only was removed")]: with self.subTest(args=args): # The option defaults of this script (M3_PRO_MESA is the M3 Pro Mesa's, once merged). script = ('die() { echo "error: $*"; exit 1; }\nM3_TRY=0\nM3_GPU_EXPERIMENT=0\nM3_PRO_MESA=1\n' diff --git a/tools/aurora-sep/tests/test_m3_persistent.py b/tools/aurora-sep/tests/test_m3_persistent.py index cdd7c17680d9..ecab5effcf86 100644 --- a/tools/aurora-sep/tests/test_m3_persistent.py +++ b/tools/aurora-sep/tests/test_m3_persistent.py @@ -160,7 +160,8 @@ def test_auto_retains_owner_off_manifest_and_model_guards(self): def test_real_option_parser_auto_and_conflicting_profiles(self): source=test_m3_handoff.INSTALLER.read_text() tail=source[source.index('\nargs=()\n'):] - for args,good in [(['--m3-gpu'],True),(['--m3-gpu','--read-only'],True), + for args,good in [(['--m3-gpu'],True),(['--m3-gpu','--desktop-fixes'],True), + (['--m3-gpu','--read-only'],False), (['--m3-gpu','--m3-gpu-persistent'],False), (['--m3-profile=j613-25g83','--m3-gpu'],False)]: with self.subTest(args=args): diff --git a/tools/aurora-sep/tests/test_m3_pro_mesa.py b/tools/aurora-sep/tests/test_m3_pro_mesa.py index 99f22d880395..f2ef380f777a 100644 --- a/tools/aurora-sep/tests/test_m3_pro_mesa.py +++ b/tools/aurora-sep/tests/test_m3_pro_mesa.py @@ -805,7 +805,7 @@ def test_how_the_script_is_read_decides_its_hash(self): ("file", ["bash", str(copy)], None, f"file {sha}"), ("relative file", ["bash", copy.name], None, f"file {sha}"), ("pipe", ["bash"], src, "stdin unavailable"), - ("pipe with arguments", ["bash", "-s", "--", "--read-only"], src, "stdin unavailable"), + ("pipe with arguments", ["bash", "-s", "--", "--no-m3-mesa"], src, "stdin unavailable"), ("process substitution", ["bash", "-c", f"bash <(cat '{copy}')"], None, "stdin unavailable")): with self.subTest(how=how): out = subprocess.run(cmd, input=stdin, capture_output=True, text=True, env=env, diff --git a/tools/aurora-sep/tests/test_sep_writes_always_on.py b/tools/aurora-sep/tests/test_sep_writes_always_on.py new file mode 100644 index 000000000000..daf3a3f3b0fe --- /dev/null +++ b/tools/aurora-sep/tests/test_sep_writes_always_on.py @@ -0,0 +1,371 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only +"""SEP writes are always on (aurora-silicon/linux#2591). + +The driver has no xart_writes or provision_keybag parameter any more, so nothing here passes or +ships one: load-driver runs a plain `modprobe apple_sep`, no modprobe.d file the packages install +sets either, and the installer refuses --read-only. An install, a re-run and --reset-touchid +delete the file an earlier --read-only install wrote, and keep any other file at that path, with +a warning. Nothing here touches the host: the installer's commands are stubbed. +""" +import os +import re +import subprocess +import tempfile +import unittest +from pathlib import Path + +SEP = Path(__file__).resolve().parents[1] +INSTALLER = SEP / "install-aurora-sep.sh" +SRC = INSTALLER.read_text() +REMOVED = "--read-only was removed: SEP writes are always on (aurora-silicon/linux#2591)" +# What an earlier --read-only install wrote to /etc/modprobe.d/aurora-sep.conf. +OLD_READ_ONLY_CONF = ( + "# aurora-sep --read-only: the driver attaches and reports, but never writes\n" + "# to the enclave. Delete this file to allow enrolment.\n" + "options apple_sep xart_writes=0 provision_keybag=0\n") +WRITE_PARAMS = re.compile(r"\b(xart_writes|provision_keybag)\b") +KEPT = "is not the file an earlier --read-only install wrote, so it stays as it is" +IGNORED = "Kernels from aurora-silicon/linux#2591 on ignore xart_writes and provision_keybag" + + +def flat(text): + return " ".join(text.split()) + + +def code_lines(text): + return [line for line in text.splitlines() if line.strip() and not line.lstrip().startswith("#")] + + +class LoadDriverTest(unittest.TestCase): + def test_modprobe_gets_no_options(self): + source = (SEP / "load-driver").read_text().split("work=$(mktemp", 1)[0] + for parameter in (None, "0"): + with self.subTest(keystore_only=parameter), tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) + param = path / "keystore_only" + if parameter is not None: + param.write_text(parameter + "\n") + modprobe = path / "modprobe" + modprobe.write_text('#!/bin/sh\nprintf "%s\\n" "$*" >>"$CALLS"\n') + modprobe.chmod(0o755) + script = path / "load-driver" + script.write_text(source.replace("/sys/module/apple_sep/parameters/keystore_only", str(param)) + .replace("/sys/bus/platform/devices", str(path / "devices"))) + calls = path / "calls" + env = dict(os.environ, AURORA_SEP_SESSION="1", CALLS=str(calls), + PATH=str(path) + os.pathsep + os.environ["PATH"]) + done = subprocess.run(["sh", str(script)], env=env, capture_output=True, text=True) + self.assertEqual(done.returncode, 0, done.stderr) + self.assertEqual(calls.read_text(), "apple_sep\n") + + def test_no_write_parameter_outside_comments(self): + for line in code_lines((SEP / "load-driver").read_text()): + self.assertNotRegex(line, WRITE_PARAMS) + + +class PackagedModprobeTest(unittest.TestCase): + def packaged_modprobe_sources(self): + found = set() + pkgbuild = (SEP / "packaging/arch/aurora-sep/PKGBUILD").read_text() + for source, dest in re.findall(r"install -Dm\d+ (\S+) (\S*modprobe\.d/\S*)", pkgbuild): + found.add(source) + spec = (SEP / "packaging/fedora/aurora-sep.spec").read_text() + sources = dict(re.findall(r"(?m)^Source(\d+):\s+(\S+)$", spec)) + for number in re.findall(r"install -D\w* \d+ %\{SOURCE(\d+)\} \S*modprobe\.d/", spec): + found.add(sources[number]) + return found + + def test_no_packaged_modprobe_file_sets_a_write_parameter(self): + sources = self.packaged_modprobe_sources() + self.assertIn("aurora-sep-load.conf", sources) + for name in sources | {p.name for p in SEP.glob("*.conf")}: + with self.subTest(file=name): + for line in code_lines((SEP / name).read_text()): + self.assertNotRegex(line, WRITE_PARAMS) + + def test_the_installer_never_writes_the_read_only_file(self): + self.assertNotRegex(SRC, r'(tee|>)\s*"?\$MODPROBE_CONF') + self.assertIsNone(re.search(r"\bREAD_ONLY\b", SRC)) + self.assertNotIn("bash -s -- --read-only", SRC) + for line in code_lines(SRC): + if "xart_writes" in line or "provision_keybag" in line: + # Only to recognise the old file, to say these are ignored, and to find + # (and tell the owner to remove) a leftover 0 a kernel from before + # linux#2591 still honours. Never to set one. + allowed = ("READ_ONLY_CONF_OPTIONS=", "ignore xart_writes", + "any xart_writes=0 or provision_keybag=0 it sets", + "modinfo -F parm apple_sep", + "sets xart_writes=0 or provision_keybag=0, and this kernel") + self.assertTrue(line.startswith(allowed[0]) or any(a in line for a in allowed[1:]), + line) + + +class InstallerTest(unittest.TestCase): + def setUp(self): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + self.tmp = Path(tmp.name) + self.conf = self.tmp / "etc/modprobe.d/aurora-sep.conf" + self.conf.parent.mkdir(parents=True) + self.calls = self.tmp / "calls" + self.calls.write_text("") + self.bin = self.tmp / "bin" + self.bin.mkdir() + # Anything that would change the host, should the script reach it, only logs. + for name in ("sudo", "pacman", "curl", "systemctl", "modprobe", "update-m1n1", + "grub-mkconfig", "mkinitcpio", "fprintd-list"): + (self.bin / name).write_text(f'#!/bin/sh\necho "{name} $*" >>"$CALLS"\nexit 1\n') + (self.bin / name).chmod(0o755) + self.env = {**os.environ, "NO_COLOR": "1", "CALLS": str(self.calls), + "PATH": f"{self.bin}{os.pathsep}{os.environ['PATH']}"} + + def sh(self, body, real_block=False): + # The real sep_block_line reads only this test's modprobe.d, never the host's. + block = (f"SEP_MODPROBE_DIRS='{self.conf.parent}'" if real_block + else "sep_block_line() { :; }") + script = f"""set -euo pipefail +AURORA_SEP_SOURCE_ONLY=1 source '{INSTALLER}' +sudo="" +MODPROBE_CONF='{self.conf}' +systemctl() {{ echo "systemctl $*" >>"$CALLS"; }} +{block} +{body} +""" + # A session of its own: no controlling terminal, so nothing can prompt on it. + return subprocess.run(["bash", "-c", script], capture_output=True, text=True, env=self.env, + start_new_session=True) + + def log(self): + return self.calls.read_text() + + def test_read_only_is_refused(self): + for args in (["--read-only"], ["--desktop-fixes", "--read-only"], ["--read-only", "--uninstall"], + ["--m3-gpu-experiment", "--read-only"], ["--reset-touchid", "--read-only"]): + with self.subTest(args=args): + proc = subprocess.run(["bash", str(INSTALLER), *args], capture_output=True, text=True, + env=self.env, start_new_session=True, stdin=subprocess.DEVNULL) + self.assertEqual(proc.returncode, 1, proc.stderr) + self.assertIn(REMOVED, proc.stderr) + self.assertEqual(proc.stdout, "") + self.assertEqual(self.log(), "") + + def test_read_only_is_not_an_option_any_more(self): + self.assertNotIn("--read-only)", SRC.replace(f'--read-only) die "{REMOVED}"', "")) + usage = re.findall(r"(?m)^# \.\.\. \| bash -s -- (\S+)", SRC[:SRC.index("\nset -euo pipefail\n")]) + self.assertIn("--uninstall", usage) + self.assertNotIn("--read-only", usage) + unknown = re.search(r'\*\) die "unknown option \$1 \(([^)]*)\)"', SRC).group(1) + self.assertNotIn("--read-only", unknown) + + def test_install_deletes_an_earlier_read_only_file(self): + for content in (OLD_READ_ONLY_CONF, OLD_READ_ONLY_CONF.rstrip("\n"), + OLD_READ_ONLY_CONF + "\n# kept for now\n", + OLD_READ_ONLY_CONF.replace("options", " options") + " \n"): + with self.subTest(content=content): + self.conf.write_text(content) + self.calls.write_text("") + proc = self.sh("sep_policy") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertFalse(self.conf.exists()) + self.assertIn(f"Removed {self.conf}, left by an earlier --read-only install: " + "SEP writes are always on", proc.stdout) + self.assertNotIn("warning", proc.stderr) + self.assertIn("systemctl enable apple-sep.path apple-sep.service", self.log()) + # A re-run finds nothing to do. + again = self.sh("sep_policy") + self.assertEqual(again.returncode, 0, again.stderr) + self.assertNotIn("Removed", again.stdout) + self.assertEqual(again.stderr, "") + + def test_install_runs_the_cleanup(self): + proc = self.sh("declare -f install_all; declare -f sep_policy") + self.assertEqual(proc.returncode, 0, proc.stderr) + install_all, sep_policy = proc.stdout.split("\nsep_policy ()", 1) + self.assertRegex(install_all, r"(?m)^\s+sep_policy;?$") + self.assertRegex(sep_policy, r"(?m)^\s+read_only_conf_cleanup;?$") + + def test_any_other_file_stays_with_a_warning(self): + target = self.tmp / "elsewhere.conf" + target.write_text(OLD_READ_ONLY_CONF) + for name, content in (("owner's", "options apple_sep xart_guard=0\n"), + ("by hand", "options apple_sep xart_writes=0 provision_keybag=0\n"), + ("edited", OLD_READ_ONLY_CONF + "options apple_sep xart_guard=0\n"), + ("blacklist", OLD_READ_ONLY_CONF + "blacklist apple_sep\n"), + ("header later", "# mine\n" + OLD_READ_ONLY_CONF), + ("empty", ""), + ("symlink", None)): + with self.subTest(file=name): + self.conf.unlink(missing_ok=True) + if content is None: + self.conf.symlink_to(target) + else: + self.conf.write_text(content) + self.calls.write_text("") + proc = self.sh("sep_policy") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertEqual(self.conf.read_text(), OLD_READ_ONLY_CONF if content is None else content) + self.assertEqual(self.conf.is_symlink(), content is None) + self.assertIn(KEPT, flat(proc.stderr)) + self.assertIn(IGNORED, flat(proc.stderr)) + self.assertNotIn("Removed", proc.stdout) + self.assertIn("systemctl enable apple-sep.path apple-sep.service", self.log()) + self.assertEqual(target.read_text(), OLD_READ_ONLY_CONF) + + def test_an_owners_block_still_wins(self): + self.conf.write_text(OLD_READ_ONLY_CONF) + proc = self.sh("sep_block_line() { echo '/etc/modprobe.d/mine.conf:1:blacklist apple_sep'; }\n" + "sep_policy") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertFalse(self.conf.exists()) + self.assertIn("apple_sep is blocked on this Mac (/etc/modprobe.d/mine.conf:1:blacklist apple_sep)", + proc.stderr) + self.assertIn("systemctl disable apple-sep.path apple-sep.service", self.log()) + self.assertNotIn("systemctl enable", self.log()) + + def test_an_owners_block_in_the_kept_file_wins(self): + # The script no longer writes $MODPROBE_CONF, so a block an owner put there counts too. + for line in ("blacklist apple_sep", "install apple-sep /bin/false"): + with self.subTest(line=line): + self.conf.write_text(OLD_READ_ONLY_CONF + line + "\n") + self.calls.write_text("") + proc = self.sh("sep_policy", real_block=True) + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertTrue(self.conf.exists()) + self.assertIn(f"apple_sep is blocked on this Mac ({self.conf}:4:{line})", flat(proc.stderr)) + self.assertIn("systemctl disable apple-sep.path apple-sep.service", self.log()) + self.assertNotIn("systemctl enable", self.log()) + + def test_the_real_block_check_ignores_options_lines(self): + self.conf.write_text("options apple_sep xart_guard=0\n") + proc = self.sh("sep_policy", real_block=True) + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertIn("systemctl enable apple-sep.path apple-sep.service", self.log()) + + def test_uninstall_removes_only_the_read_only_file(self): + proc = self.sh("declare -f uninstall_all") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertRegex(proc.stdout, r"(?m)^\s+read_only_conf_cleanup;?$") + self.assertNotIn('rm -f "$MODPROBE_CONF"', proc.stdout) + + def test_the_write_notice_offers_no_read_only_install(self): + self.conf.write_text(OLD_READ_ONLY_CONF) + proc = self.sh("sep_write_notice") + self.assertEqual(proc.returncode, 0, proc.stderr) + err = flat(proc.stderr) + self.assertIn("the SEP driver creates an identity keybag and writes to the enclave's anti-replay " + "store (xART). SEP writes are always on. Use a Mac you can DFU-restore", err) + self.assertNotIn("read-only", err) + # An owner's block: the driver is not loaded, so there is nothing to warn about. + proc = self.sh("sep_block_line() { echo '/etc/modprobe.d/mine.conf:1:blacklist apple_sep'; }\n" + "sep_write_notice") + self.assertEqual((proc.returncode, proc.stderr), (0, "")) + + def test_the_agent_prompt_offers_no_read_only_install(self): + start = SRC.index("SAFETY, NON-NEGOTIABLE") + safety = flat(SRC[start:SRC.index("\nPROMPT\n", start)]) + self.assertIn("SEP writes are always on; there is no read-only install.", safety) + self.assertIn("If the owner cannot DFU-restore, do not install.", safety) + self.assertNotIn("--read-only", safety) + + # --reset-touchid with its commands stubbed: the device tree says Apple, the driver reports a + # failed keybag, and the state "moves" only into the log. + RESET_STUBS = r""" +grep() { if [[ ${!#} == /proc/device-tree/compatible ]]; then return 0; fi; command grep "$@"; } +sep_diag() { echo failed; } +sleep() { :; } +find() { :; } +mkdir() { echo "mkdir $*" >>"$CALLS"; } +mv() { echo "mv $*" >>"$CALLS"; } +""" + + def reset(self, *args): + state = self.tmp / "aurora-sep-keybag.bin" + state.write_text("keybag") + return self.sh(f"{self.RESET_STUBS}\nTOUCHID_STATE_FILES=('{state}')\n" + f"reset_touchid {' '.join(args)}") + + def test_reset_touchid_is_not_refused_for_the_read_only_file(self): + self.conf.write_text(OLD_READ_ONLY_CONF) + proc = self.reset("--yes") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertNotIn("installed read-only", proc.stderr) + self.assertFalse(self.conf.exists()) + self.assertIn(f"Removed {self.conf}, left by an earlier --read-only install", proc.stdout) + self.assertIn("Moved the Touch ID state to /var/lib/aurora-sep-touchid-reset-", proc.stdout) + self.assertIn("systemctl mask --runtime --now fprintd.service", self.log()) + self.assertIn(f"mv {self.tmp / 'aurora-sep-keybag.bin'} ", self.log()) + + def test_reset_touchid_changes_nothing_before_it_is_confirmed(self): + self.conf.write_text(OLD_READ_ONLY_CONF) + proc = self.reset() + self.assertNotEqual(proc.returncode, 0) + self.assertIn("no terminal to confirm on; run again with --reset-touchid --yes", proc.stderr) + self.assertEqual(self.conf.read_text(), OLD_READ_ONLY_CONF) + self.assertEqual(self.log(), "") + + def modinfo(self, parms): + (self.bin / "modinfo").write_text("#!/bin/sh\nprintf '%s' \"$PARMS\"\n") + (self.bin / "modinfo").chmod(0o755) + self.env["PARMS"] = parms + + OLD_PARMS = "xart_writes:Allow shared xART writes (u8)\nprovision_keybag:Create the keybag (u8)\n" + NEW_PARMS = "xart_guard:-1: the platform's level (i8)\n" + + def test_kept_conf_turns_writes_off(self): + cases = [("options apple_sep xart_writes=0 provision_keybag=0\n", self.OLD_PARMS, True), + ("options apple-sep provision-keybag=0\n", self.OLD_PARMS, True), + ("options apple_sep xart_guard=0 xart_writes=00\n", self.OLD_PARMS, True), + ("options apple_sep xart_writes=0 provision_keybag=0\n", self.NEW_PARMS, False), + ("options apple_sep xart_guard=0\n", self.OLD_PARMS, False), + ("options apple_sep xart_writes=1\n", self.OLD_PARMS, False), + ("# options apple_sep xart_writes=0\n", self.OLD_PARMS, False), + (OLD_READ_ONLY_CONF, self.OLD_PARMS, False)] + for content, parms, off in cases: + with self.subTest(content=content, parms=parms): + self.conf.write_text(content) + self.modinfo(parms) + proc = self.sh("kept_conf_turns_writes_off && echo OFF || echo ON") + self.assertEqual(proc.stdout.strip(), "OFF" if off else "ON", proc.stderr) + + def test_reset_touchid_refuses_an_owners_off_setting_on_an_old_kernel(self): + self.conf.write_text("options apple_sep xart_writes=0 provision_keybag=0\n") + self.modinfo(self.OLD_PARMS) + proc = self.reset("--yes") + self.assertNotEqual(proc.returncode, 0) + self.assertIn("still honours it: the next boot could not create a new keybag", flat(proc.stderr)) + self.assertEqual(self.log(), "") + # The same file under a kernel without the parameters: the reset goes ahead. + self.modinfo(self.NEW_PARMS) + proc = self.reset("--yes") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertIn("Moved the Touch ID state", proc.stdout) + + def test_reset_touchid_stops_if_the_read_only_file_stays(self): + # rm fails (a read-only /etc, say): nothing is moved, and the reset says why. + self.conf.write_text(OLD_READ_ONLY_CONF) + state = self.tmp / "aurora-sep-keybag.bin" + state.write_text("keybag") + proc = self.sh(f"{self.RESET_STUBS}\nrm() {{ return 1; }}\nTOUCHID_STATE_FILES=('{state}')\n" + "reset_touchid --yes") + self.assertNotEqual(proc.returncode, 0) + self.assertIn("could not be removed; nothing was reset", flat(proc.stderr)) + self.assertEqual(self.conf.read_text(), OLD_READ_ONLY_CONF) + self.assertNotIn("systemctl mask", self.log()) + self.assertNotIn("mv ", self.log()) + + def test_the_modprobe_dirs_override_is_test_only(self): + self.assertIn('SEP_MODPROBE_DIRS=${AURORA_SEP_TEST_MODPROBE_DIRS:-', SRC) + self.assertNotIn("${SEP_MODPROBE_DIRS:-", SRC) + + def test_reset_touchid_keeps_an_owners_file(self): + self.conf.write_text("options apple_sep xart_guard=0\n") + proc = self.reset("--yes") + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertEqual(self.conf.read_text(), "options apple_sep xart_guard=0\n") + self.assertIn(KEPT, flat(proc.stderr)) + self.assertIn("Moved the Touch ID state", proc.stdout) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/aurora-sep/tests/test_unsupported_soc.py b/tools/aurora-sep/tests/test_unsupported_soc.py index 3615def9e275..ae035b2f089b 100644 --- a/tools/aurora-sep/tests/test_unsupported_soc.py +++ b/tools/aurora-sep/tests/test_unsupported_soc.py @@ -72,11 +72,19 @@ def test_install_refuses_before_anything(self): self.assertFalse(self.m1n1_conf.exists()) self.assertFalse(self.state.exists() and any(self.state.iterdir())) - def test_read_only_install_refuses_too(self): - self.mac("j713") - proc = self.run_sh("READ_ONLY=1\ninstall_all", check=False) - self.assertNotEqual(proc.returncode, 0) - self.assertIn("apple,t8132", proc.stderr) + def test_install_options_refuse_too(self): + # An install with one of its options refuses the same way, before the option acts. + for option in ("ESP_ARCHIVE_HISTORY=1", "DESKTOP_FIXES=1", "M3_PRO_MESA=0"): + with self.subTest(option=option): + self.mac("j713") + before = self.boot.read_bytes() + proc = self.run_sh(f"esp_history_run() {{ echo ARCHIVE; }}\n{option}\ninstall_all", + check=False) + self.assertNotEqual(proc.returncode, 0) + self.assertIn("apple,t8132", proc.stderr) + self.assertNotIn("ARCHIVE", proc.stdout) + self.assertEqual(self.boot.read_bytes(), before) + self.assertEqual(self.downloaded(), []) def test_uninstall_refuses(self): for board, soc in UNSUPPORTED.items():