Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/sep-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 32 additions & 30 deletions Documentation/ABI/testing/sysfs-driver-apple-sep
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -98,14 +99,21 @@ KernelVersion: 7.1
Contact: Chris Kearney <chris@kearneymail.com>
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/<unit>.sep/diag/attach
Expand Down Expand Up @@ -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/<unit>.sep/diag/sensor
Date: October 2026
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -388,18 +387,19 @@ 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
be retried. Returns EINVAL for other values, or if the driver
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
Expand All @@ -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.
Expand All @@ -422,7 +422,9 @@ Contact: Satya Benson <satya@benson.earth>
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.
Expand Down
8 changes: 4 additions & 4 deletions drivers/soc/apple/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 6 additions & 7 deletions drivers/soc/apple/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>) -> bool {
xart_writes && user_bags && guard.is_none()
pub(crate) fn initrd_xart_writes(user_bags: bool, guard: Option<u8>) -> bool {
user_bags && guard.is_none()
}

/// Holds the callback context alive until sysfs has drained all writers.
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions drivers/soc/apple/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions drivers/soc/apple/diag_shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static struct {
bool cold;
bool sepos13;
bool xart;
bool provision_keybag;
bool trusted_keys;
bool filevault_api;
bool xarm_trace;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
38 changes: 16 additions & 22 deletions drivers/soc/apple/sbio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -5829,15 +5822,16 @@ 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.
if bio::starts_capture(cmd) && !self.xart_writable() {
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);
Expand Down Expand Up @@ -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);
}
Expand Down
Loading
Loading