Repository navigation
soc: apple: sep: seal a disk-encryption secret to a user's key bag, per OS install, unlockable from the initrd - #1339
Conversation
Keep host state, identity-index loading and biometric device publication off until the real root completes the original attach. Open xART read-only in the initrd, suppress keybag and ref-key provisioning, and cache trusted-key material without retaining initrd file handles. Refuse an unseal when persistent-state writes were denied, while preserving the real root's boot-policy window. Add the root-only complete_attach attribute and let load-driver finish an initrd-loaded module without another SEP registration. Cover completion rejection, retries and idempotence in KUnit, plus production cache, refusal and loader paths in buildbox host tests. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
SYNC_FILE selects the hidden DMA_SHARED_BUFFER symbol required by SEP. Setting the hidden symbol alone is ignored by Kconfig. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
FileVault ties the volume key to the user's password through the enclave: the password goes to the enclave, which entangles it with its UID key and counts failed attempts, and only then releases the key. The per-user bags give Linux the same gate; this adds the key release. SEP_BIO_FDE_CREATE (0x37) makes a P-256 ref-key under the designated, unlocked bag of a uid (protection class 9, no access-control list), so the enclave uses it only while that bag is unlocked. SEP_BIO_FDE_SEAL (0x38) ECIES-encrypts up to 64 bytes to it and has the enclave open the result once before returning it. SEP_BIO_FDE_UNSEAL (0x39) asks the enclave to open a sealed blob. Root only, on the re-arm node, variant-5 key store only, like the other user-bag ioctls. A LUKS2 token keeps the wrapped bag, the record and the sealed key-slot secret in the header, none of which opens without the password on this Mac. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
# Conflicts: # drivers/soc/apple/userbag.rs
struct sep_fde_seal is 2.4 KiB and struct sep_fde_key 2 KiB. Copy them to the heap in the FDE_CREATE/SEAL/UNSEAL handlers, as EXPORT/IMPORT do for the wrapped bag. The SEAL/UNSEAL buffer carries the volume secret and is wiped when it is dropped.
After the lock transition the key store holds the bag in its locking phase, class keys still usable, until the grace timer fires. The LOCK ioctl fired it only for a screen lock with no grace, so a logout or suspend lock left the bag's keys open: on the Neo a key sealed under a user bag still unsealed after SEP_BIO_KEYBAG_LOCK with the logout reason, and was refused once the timer was fired. Fire it for every lock but a screen lock with a grace period. Assisted-by: LLM
Firing the grace timer does not end the key store's locking phase early: on the Neo the store answers the timer with no handle until its own deadline (about 40 s after the lock transition, for every lock reason), so the change only turned logout and suspend locks into EAGAIN. The bag reaches the locked phase by itself at that deadline, and a key sealed under it is refused from then on. Assisted-by: LLM
|
Hardware rows on the Neo (variant-5 key store), kernel 7.3.0-aurora-sepfde3 (
The 1504-byte bag needed #921's 4 KiB Still open:
|
|
Cross-Mac row on the J616s, kernel 7.3.0-aurora-sepfdej1 (fleet46 base plus this branch). The Neo's container file and its current password are presented to the J616s enclave. Its Secure Enclave does not accept the token ( |
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
…y=2) A root volume sealed to a user's password (SEP_BIO_FDE_*) has to open before the real root is mounted, the way FileVault asks for the password once after a cold boot. keystore_only=1 attaches the key store for trusted keys only and keeps xART read-only, so a saved user bag can neither be loaded nor unlocked there. keystore_only=2 adds that unlock to the initrd phase: - /dev/sep-bio-rearm is published as soon as the key store is open. Until complete_attach it serves only what a password unlock needs: state, import, unlock, lock and FDE unseal. Create, change, export and the FDE create/seal requests return EAGAIN; enrolment stays on the real root. - Loading and unlocking a bag needs enclave writes to the gigalocker, so xART follows xart_writes in this mode, but only while the xART guard is off: the guard's record list lives in host files on the real root, which the initrd must not write. With a guard, xART stays read-only, the bag requests fail with EROFS and the volume falls back to its passphrase. - Nothing changes for keystore_only=0 or 1. complete_attach is unchanged and publishes the rest of the node's requests. load-driver completes the attach for either initrd mode. KUnit: the initrd request subset and the initrd xART write rule. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
A sealed volume secret opened for any Linux install on the Mac whose user bag it was sealed under. FileVault ties a volume key to its volume, so do the same here: FDE_SEAL frames the secret with the kernel's OS identity (the os_uuid_hi/lo parameters, else /chosen/apfs-preboot-uuid) inside the ECIES envelope, and FDE_UNSEAL returns the secret only when the identity inside matches. Another install gets EXDEV, so user space can tell it from a refused unseal (EKEYREJECTED); a kernel without an identity gets ENOKEY. A plaintext without the frame is refused. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
|
24e66c3 binds the sealed secret to the OS install: the sealed plaintext is Hardware, MacBook Neo, 7.3.0-aurora-secdec1 (fleet59 + #921 + this branch + #1471), aurora-sep-userspace#23 tools, LUKS2 test container file:
|
sks_machine_refkey() now returns without creating a ref-key in the key-store-only initrd phase. Give the fixture the keystore_only flag and check that phase never creates one, whatever the store open returns.
FileVault ties a volume key to the user's password through the Secure Enclave. The password goes to the enclave, which checks it, entangles it with its UID key, counts failed attempts and then releases the key. The per-user key bags give Linux the same gate. This PR adds the key release, binds each release to one OS install, and adds the key-store-only initrd attach so the root volume can unlock this way.
FDE key release. Three ioctls on the root-only re-arm node, variant-5 key store only. They are built from the existing ref-key and user-bag primitives, with no new enclave wire protocol.
SEP_BIO_FDE_CREATE(0x37): creates a P-256 sealing key under the designated, unlocked bag of a uid (class 9, no ACL). The enclave uses it only while that bag is unlocked.SEP_BIO_FDE_SEAL(0x38): ECIES-encrypts up to 64 bytes to that key, then has the enclave open the result once before returning it.SEP_BIO_FDE_UNSEAL(0x39): opens a sealed blob. The enclave does this only while the bag is unlocked, and only on the Mac that made the key.Per-OS-install binding, like FileVault's per-volume key:
os_uuid_hi/os_uuid_lopin, else/chosen/apfs-preboot-uuid.EXDEV. A kernel with no identity returnsENOKEY.Key-store-only initrd attach (
apple_sep.keystore_only):1: the initrd attaches the SEP key store for trusted keys only. Touch ID and the host-state store wait until the real root writescomplete_attach.2: as1, plus/dev/sep-bio-rearmserves a password unlock of a per-user key bag in the initrd. Only state, import, unlock, lock and FDE unseal are served. Create, change, export and FDE create/seal returnEAGAINuntilcomplete_attach.2, xART followsxart_writesonly while the xART guard is off. With a guard, the bag requests fail withEROFSand the volume falls back to its passphrase or recovery key.Userspace (aurora-sep-userspace
aurora-sep-fdeand its LUKS2 token) keeps the wrapped bag, the key record and the sealed key-slot secret in anaurora-sepLUKS2 token.Tests
drivers/soc/apple/sep.kunitconfigon this branch: 509 tests, 507 pass, 2 skipped (not SEP tests).tools/aurora-sep/testssource checks pass (the ref-key fixture now covers the key-store-only phase).os_uuidpin: the unseal is refused withEXDEV("belongs to another OS install"), and back on the pinned install it opens;Assisted-by: LLM