diff --git a/drivers/soc/apple/profile.rs b/drivers/soc/apple/profile.rs index c87d46f44eb9f..d24b0b25bf3ba 100644 --- a/drivers/soc/apple/profile.rs +++ b/drivers/soc/apple/profile.rs @@ -185,11 +185,29 @@ pub(crate) struct PlatformProfile { pub(crate) key_store: KeyStore, /// Platforms with reboot-tested owner export and user-before-master saves. pub(crate) persistent_enrol: bool, + /// The enclave never answers a user-bag `DESIGNATE_KEYBAG`, and that + /// unanswered request condemns the SKS endpoint for the rest of the boot + /// (`sks_wedged`), taking the whole key store down. Measured on T8112 + /// (J415, OS firmware 26.6.2): CREATE_KEYBAG returns a handle, then + /// DESIGNATE_KEYBAG gets no reply. Such an enclave refuses per-user key + /// bags with `EOPNOTSUPP` before any request is sent (see + /// [`PlatformProfile::per_user_keybags`]). + pub(crate) designate_unanswered: bool, /// The `xart_guard` level when the parameter is left at its default (see /// [`crate::xart_guard`]). pub(crate) xart_guard: u8, } +impl PlatformProfile { + /// Whether the enclave can create and designate a NEW per-user key bag + /// (`userbag_ioctl`, linux#921). The user-bag requests are the variant-5 + /// key store's; the 13.5 key store has no such request shapes. An enclave + /// with the measured unanswered-DESIGNATE defect is the exception. + pub(crate) const fn per_user_keybags(&self) -> bool { + matches!(self.key_store, KeyStore::Variant5) && !self.designate_unanswered + } +} + pub(crate) const T8103: PlatformProfile = PlatformProfile { name: "T8103/J313", shmem_capacity: 0x3_0000, @@ -222,6 +240,7 @@ pub(crate) const T8103: PlatformProfile = PlatformProfile { cpx_encryption_mode: 2, }, persistent_enrol: true, + designate_unanswered: false, nonce_session: false, // Off: Touch ID setup on a cold-boot SEP rewrites a session record that // predates Linux, so the guard would only block it. @@ -263,6 +282,7 @@ pub(crate) const T6000: PlatformProfile = PlatformProfile { cpx_encryption_mode: 2, }, persistent_enrol: true, + designate_unanswered: false, nonce_session: false, // As T8103. On J316s, creating the identity keybag also rewrites a // session record that predates Linux. @@ -297,6 +317,8 @@ pub(crate) const T6020: PlatformProfile = PlatformProfile { }, key_store: KeyStore::Variant5, persistent_enrol: true, + // Not measured: no M2 Pro/Max has run a user-bag DESIGNATE. + designate_unanswered: false, nonce_session: false, // A warm-attach enclave shared with macOS, as on T8112. xart_guard: 1, @@ -326,6 +348,8 @@ pub(crate) const T6020_SEPOS13: PlatformProfile = PlatformProfile { pub(crate) const T8140: PlatformProfile = PlatformProfile { key_store: KeyStore::Variant5, persistent_enrol: true, + // J700 answers the user-bag CREATE and DESIGNATE (variant-5 capture). + designate_unanswered: false, name: "T8140/J700", shmem_capacity: 0x4_0000, shmem_first_item: b"CINP", @@ -398,6 +422,8 @@ pub(crate) const T8112: PlatformProfile = PlatformProfile { }, key_store: KeyStore::Variant5, persistent_enrol: true, + // J415 never answers a user-bag DESIGNATE_KEYBAG (see the field). + designate_unanswered: true, nonce_session: false, // Guarded from its first Linux boot (2026-10-16): no record refused. xart_guard: 1, @@ -427,6 +453,10 @@ pub(crate) const T8122: PlatformProfile = PlatformProfile { dart_window: &DART_HIGH_ALIAS, // A warm-attach enclave shared with macOS, as on T8112. xart_guard: 1, + // The unanswered DESIGNATE is a J415 measurement, not a property of the + // T8112 profile this one extends; no M3 (nor the M4/M5 Airs extending + // this) has run a user-bag DESIGNATE. + designate_unanswered: false, ..T8112 }; @@ -771,6 +801,25 @@ mod tests { assert!(T6040.xart_guard == 1); } + #[test] + fn per_user_keybags_follow_the_key_store_and_the_designate_defect() { + // The 13.5 key store has no user-bag requests. + assert!(!T8103.per_user_keybags()); + assert!(!T6000.per_user_keybags()); + assert!(!T6020_SEPOS13.per_user_keybags()); + // The measured unanswered DESIGNATE. + assert!(T8112.designate_unanswered); + assert!(!T8112.per_user_keybags()); + // Every other variant-5 enclave. + for p in [ + &T6020, &T8140, &T8122, &T6040, &T6041, &T6050, &T8132, &T8142, + ] { + assert!(p.key_store == KeyStore::Variant5); + assert!(!p.designate_unanswered); + assert!(p.per_user_keybags()); + } + } + /// The name of the profile `select` picks for a root `compatible` list. fn picked(compatibles: &[&[u8]]) -> Option<&'static str> { let has = |c: &[u8]| compatibles.iter().any(|x| *x == c); diff --git a/drivers/soc/apple/refkey.rs b/drivers/soc/apple/refkey.rs index f0fde4827754a..c92dd28cfa1b8 100644 --- a/drivers/soc/apple/refkey.rs +++ b/drivers/soc/apple/refkey.rs @@ -537,7 +537,7 @@ impl SepData { user: crate::sks::DesignateUser, acl: Option<&[u8]>, ) -> Result> { - if self.profile.key_store != profile::KeyStore::Variant5 { + if !self.profile.per_user_keybags() { return Err(EOPNOTSUPP); } crate::xart_guard::close_policy_window(); @@ -601,7 +601,7 @@ impl SepData { /// caller has unlocked the bag with the user's password. Variant-5 key /// store only. pub(crate) fn fde_key_create(&self, user: crate::sks::DesignateUser) -> Result> { - if self.profile.key_store != profile::KeyStore::Variant5 { + if !self.profile.per_user_keybags() { return Err(EOPNOTSUPP); } crate::xart_guard::close_policy_window(); @@ -651,7 +651,7 @@ impl SepData { record: &[u8], sealed: &[u8], ) -> Result> { - if self.profile.key_store != profile::KeyStore::Variant5 { + if !self.profile.per_user_keybags() { return Err(EOPNOTSUPP); } Self::refkey_pub(record).ok_or(EINVAL)?; diff --git a/drivers/soc/apple/userbag.rs b/drivers/soc/apple/userbag.rs index 5b6bdeff833fb..3c27b8dbe0327 100644 --- a/drivers/soc/apple/userbag.rs +++ b/drivers/soc/apple/userbag.rs @@ -1304,13 +1304,13 @@ impl crate::SepData { pub(crate) fn userbag_ioctl(&self, cmd: u32, arg: usize) -> Result { crate::bio::require_admin()?; - if self.profile.key_store != crate::profile::KeyStore::Variant5 { - // The user-bag layouts were captured on the variant-5 key store - // (macOS 26 on the Neo). The 13.x key store of M1/M2-generation - // Macs has not been captured, so nothing is sent there. + if !self.profile.per_user_keybags() { + // The 13.5 key store has no user-bag requests, and an enclave + // that never answers a user-bag DESIGNATE_KEYBAG would condemn + // the SKS endpoint for the boot: refuse before sending anything. dev_info_ratelimited!( self.dev, - "userbag: per-user key bags are not supported on this key store yet (only variant 5 has been captured)\n" + "userbag: per-user key bags are not supported on this Mac's Secure Enclave key store\n" ); return Err(EOPNOTSUPP); }