Skip to content

soc: apple: sep: report a refused identity unlock, and stop aurora-sep-load on it - #3274

Merged
RyanTheTide merged 4 commits into
mainfrom
fix/sep-refused-fastfail
Nov 28, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
fix/sep-refused-fastfail

Conversation

@erikwb

@erikwb erikwb commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: On the 13.5 DEVICE_STATE_TRANSITION identity key-bag unlock path (sks_prepare_identity_refkey(); variant-5 key stores unlock the identity bag via sks_req_change_lock_state on a separate path), when the enclave refuses the unlock, tools/aurora-sep/load-driver (aurora-sep-load) retried the trusted-key seal 10 times a second for 120 s, and aurora-sep-ready → aurora-touchid-boot held multi-user.target (and the desktop session) for 90 s behind it. The driver now reports refusals from that DEVICE_STATE_TRANSITION identity-unlock path in a new diag/trusted attribute (unknown / ready / refused <status>), clears stale refusals on a later validated DEVICE_STATE_TRANSITION identity unlock, and the loader stops at the first refusal.
Tested: At 2cdd990f389e (adds only the tools/aurora-sep/tests/test_diag_sensor.py stub-header fix over 77114190bfb4; all kernel, driver, ABI documentation, and tools/aurora-sep/load-driver files are byte-for-byte unchanged from 77114190bfb4): python3 -m unittest tools/aurora-sep/tests/test_diag_policy.py tools/aurora-sep/tests/test_diag_sensor.py -v (4/4, and 4/4 with -O), tools/aurora-sep/tests/test_trusted_refused.py (8/8), tools/asahi/run-host-tests.py --only sep-suspend (22/22), the remaining sep-source.yml unit suites (120/120 across normal and -O runs), and scripts/checkpatch.pl --strict --git 77114190bfb4..HEAD (0 errors, 0 warnings, 0 checks). Driver and loader runtime at 77114190bfb4 (unchanged in 2cdd990f389e): J313 (M1 Air, T8103, 27.2.1 firmware) in fleet candidate 5509a254a6bd (main fcb124279183 plus unchanged heads 038ab73f52a6 (#3220), 5c89fbdf4ddc (#3221), 2b1bab104938 (#3297), 4b09f0691c2d (#3300), d3cf4ca61518 (#3329), b8530d17c96b (#3332), 262e263dae4c (#3333), and 77114190bfb4 (#3274), merged without conflicts), default command line, J313 device tree built from the candidate on default Stage 2 (1.0.0b17-gf5ddfff2) as a one-shot aura-try, kernel installed next to the default and removed afterwards, Mac docked (Thunderbolt 5 dock with Ethernet and a 3840x2160@120 external display on dcpext), with this PR's tools/aurora-sep/load-driver installed as /usr/libexec/aurora-sep-load for the run (packaged loader restored afterwards): diag/protocol reads sepos13 and diag/trusted reads ready; aurora-sep.service logged trusted keys work after 4 s and /dev/sep-bio is available, with 0 key_seal failed and 0 identity unlock refused lines; graphical.target at 6.9-7.0 s (systemd-analyze 8.5 s); a re-run of the service took 0.6 s and logged trusted keys work after 0 s; diag/trusted stayed ready across 2 deep sleeps and an s2idle; 0 failed units, 0 AppArmor denials (on that boot the enclave unlocked the identity key bag, so the refused <status> branch was not reached at 77114190bfb4, covered by the earlier J313 row at d32a863c55ff where diag/trusted read refused -8, 1 refused seal per boot vs 905, graphical.target at 7.19 s vs 91.9 s, fprintd re-runs sent no seal, and 1 deep sleep resumed); J716c (M5 Max, T6050, variant-5 key store) in candidate 3e4078f656d5 (main fcb124279183 plus unchanged 77114190bfb4 and sibling PRs, default command line, with this PR's tools/aurora-sep/load-driver run): diag/protocol reads variant5, diag/trusted reads ready, aurora-sep-load logged trusted keys work after 1 s and /dev/sep-bio is available (rc 0), aurora-sep-ready.service active, 0 new failed units (aurora-peripherals.service and systemd-networkd-wait-online.service also fail on default), 0 LSM denials, 0 SEP kernel errors (3 boot err lines total: 2x pre-existing systemd-gpt-auto-generator plus aurora GPU EPROBE_DEFER at 0.65 s); SEP KUnit (apple_sep*) 319/319 pass.
Risk: two-way door · every Mac with the SEP driver (one whose enclave unlocks the bag or uses the variant-5 key store only ever sees unknown and ready, and its loader path is unchanged)
Not yet: a J313 run where the enclave refuses the identity unlock at 77114190bfb4 / 2cdd990f389e (the refused -8 row ran at d32a863c55ff; at 77114190bfb4 the J313 enclave unlocked the bag).

Details

Why the desktop waited. On the J313 with 27.2.1 firmware the enclave can answer the 13.5 identity unlock (DEVICE_STATE_TRANSITION) with status -8 on boot, so no trusted key can be sealed. aurora-sep-load could not see that and probed until its 120 s deadline. aurora-sep-ready.service (Requires=/After=aurora-sep.service, JobTimeoutSec=90) waited for it, and aurora-touchid-boot.service (WantedBy=multi-user.target, After=aurora-sep-ready.service) waited for that. So multi-user.target and graphical.target came up only at 91.9 s, and uwsm sat on a black screen through its 60 s "graphical.target is queued" countdown.

Driver (soc: apple: sep: report a refused identity unlock in diag/trusted, soc: apple: sep: clear stale diag/trusted refusal on identity unlock).

  • sks_prepare_identity_refkey() records refused <status> when the enclave answers the unlock with a non-zero status (a reply, not a lost one).
  • When a subsequent DEVICE_STATE_TRANSITION reply validates (mailbox status 0 and 20-byte zero-header response, including via /dev/sep-key's with_identity_bag()), sep_diag_clear_trusted_refusal() atomically clears refused <status> back to unknown while leaving ready untouched so ready stays tied to a working trusted-key unseal and a subsequent loader run probes again.
  • refkey_unseal_trusted() records ready after an unseal passes its write-refusal check. A seal unseals its own new blob before returning it, so a working seal also reads ready.
  • The state and the status share one atomic word, the value resets to unknown at bind, and sep_diag_clear_trusted_refusal() uses atomic_try_cmpxchg() so a reader never pairs a state with another refusal's status.
  • The value comes only from the enclave's answer: no chip, board or firmware gate. The diag ABI stays at version 3 (attributes are only added); documented in sysfs-driver-apple-sep.

Loader (tools/aurora-sep: stop the loader when the enclave refuses the unlock).

  • After each failed probe it reads diag/trusted, and at refused* it logs the status and exits 1. It says that the key bag and ref-key are kept, and not to replace them.
  • A run started again in the same boot reads the attribute before probing, so it sends no seal.
  • An xART guard refusal is still checked first and keeps its own message, since it has a way out (aurora-sep-policy-change).
  • Kernels without diag/trusted read nothing there and keep the probe-until-deadline behaviour, as do enclaves that answer late rather than refuse.

Host test stubs (tools/aurora-sep: define atomic_t in stub linux/types.h).

  • drivers/soc/apple/shim.h includes <linux/types.h> (where the kernel defines atomic_t) for its sep_diag_*_atomic(atomic_t *, ...) prototypes.
  • tools/aurora-sep/tests/test_diag_sensor.py now defines typedef struct { int counter; } atomic_t; in its stub linux/types.h instead of linux/atomic.h (which retains the atomic_* operations), so harnesses including "shim.h" without <linux/atomic.h> compile cleanly without modifying any driver header.

Left as is. fprintd.service still Requires=aurora-sep.service, so each fprintd activation starts the unit again; each start now exits in milliseconds with no SEP traffic. The packaged pkgrel/Release are not bumped here.

Evidence

Same Mac, same session, default command line. A = baseline main at 859e8a29796c with the packaged loader (aurora-sep 1-25). B = this PR at tested head d32a863c55ff, built with the J313 config, booted once via grub-reboot, with the PR's load-driver installed as /usr/libexec/aurora-sep-load.

A: before B: this PR (d32a863c55ff)
systemd-analyze 2 min 2.054 s (userspace 2 min 0.622 s) 7.199 s (userspace 5.784 s)
graphical.target reached 91.9 s 7.19 s
uwsm "waiting for 60s" ran out its full countdown, Hyprland at 68.6 s ended after 4 s, Hyprland at 8.0 s
aurora-sep.service first run 119.4 s wall, 7.364 s CPU, "did not seal and unseal a trusted key within 120 s" 4.0 s wall (first refused probe right after the key store opened), exit 1 with the refusal line below
key_seal failed lines this boot 905 (at 122 s) 1
identity unlock refused lines 230 (ratelimited) 1
re-runs from fprintd — 2 (10.19 s and 10.23 s), each exited in about 30 ms with no seal
diag/trusted (attribute absent) refused -8
deep sleep (rtcwake -d rtc1 -m mem -s 12) — entered 16:34:32.35, resumed 16:34:46.99; diag/trusted still refused -8
failed units aurora-sep.service aurora-sep.service (expected: the enclave refuses the unlock)
SELinux AVC denials 0 0
kernel err lines 2 (apple-dcp ... AFK[ep:20]: failed to extract init props: -2) 2 at boot (same DCP lines); after the deep sleep also the resume lines below

Loader line on B:

aurora-sep-load: the enclave refused to unlock the identity key bag that trusted keys need (diag/trusted: refused -8). Asking again gets the same answer, so this run stops here; trusted keys are unavailable this boot. The key bag and ref-key are left as they are: do not replace them to get past this

Resume on B also logged PS fpwm1: Failed to reach power state 0xf, and Unable to change power state from D3hot to D0 for brcmfmac and hci_bcm4377. Both drivers rebound by themselves (wlan0 came back up, ssh kept working). The trial kernel is main, which lacks the T8103 PCIe sleep handling in open #3221. The lines are the same on the pre-rebase row and do not involve the SEP.

Earlier row on the pre-rebase head 12d3f541d9d8 (main 40e5e29cc915 + these two commits, same Mac): refused -8, 1 key_seal failed, graphical.target 7.2 s (systemd-analyze 7.174 s), re-runs at 10.0 s with no seal, deep sleep 16:10:31.57 → 16:10:46.55. The rebase onto main resolved one conflict in diag_shim.c next to #3168's kernfs fields, so the row above was run again at d32a863c55ff.

  • J313 (M1 Air, T8103, 27.2.1 firmware) at 77114190bfb4 in fleet candidate 5509a254a6bd (default command line, PR tools/aurora-sep/load-driver run): diag/protocol sepos13, diag/trusted ready, aurora-sep.service logged trusted keys work after 4 s and /dev/sep-bio is available (0 key_seal failed, 0 identity unlock refused), graphical.target 6.9-7.0 s (systemd-analyze 8.5 s), re-run 0.6 s (trusted keys work after 0 s), diag/trusted stayed ready across 2 deep sleeps and 1 s2idle, 0 failed units, 0 AppArmor denials.
  • J716c (M5 Max, T6050, variant-5 key store) at 77114190bfb4 in candidate 3e4078f656d5 (default command line, PR tools/aurora-sep/load-driver run): diag/protocol variant5, diag/trusted ready, aurora-sep-load: trusted keys work after 1 s, /dev/sep-bio is available, rc 0, aurora-sep-ready.service active; 0 new failed units (aurora-peripherals.service and systemd-networkd-wait-online.service also fail on default), 0 LSM denials, 0 SEP kernel errors (3 boot err lines: 2x systemd-gpt-auto-generator plus aurora GPU EPROBE_DEFER at 0.65 s before GPU came up).

Off-Mac at 2cdd990f389e (host-test-only over 77114190bfb4):

  • python3 -m unittest tools/aurora-sep/tests/test_diag_policy.py tools/aurora-sep/tests/test_diag_sensor.py -v: 4/4 passed (and 4/4 with python3 -O).
  • python3 -m unittest tools/aurora-sep/tests/test_trusted_refused.py -v: 8/8 passed.
  • python3 -I tools/asahi/run-host-tests.py --only sep-suspend: 22/22 passed.
  • tools/aurora-sep/tests/ remaining sep-source.yml unit tests (test_store_open_errors.py normal and -O, test_identity_preservation.py normal and -O, test_sep_bio_identities.py, test_orphan_delete.py, test_enrol_admission.py, test_owner_preparation.py, test_policy_window.py, test_log_ratelimit.py, test_key_context_cleanup.py, test_packaging.py, test_sep_writes_always_on.py, test_boot_locks.py, test_kernel_log_anchor.py, test_collect_handover.py, test_touchid_package.py, test_root_staging.py): 120/120 passed.
  • scripts/checkpatch.pl --strict --git 77114190bfb4..HEAD: 0 errors, 0 warnings, 0 checks.

Off-Mac at 77114190bfb4 (unchanged driver/KUnit code):

  • SEP KUnit (drivers/soc/apple/sep.kunitconfig, QEMU arm64, 'apple_sep*'): 319/319 passed (including 2 new apple_sep_refkey_trusted subtests, run against a test-owned atomic without modifying live diag/trusted).
  • tools/aurora-sep/tests/test_keystore_only.py passes KeyStoreCacheTests (7/7) and LoaderTests (1/1) while MachineRefkeyTests has the same pre-existing sks_create_refkey argument-count failure as main.
  • checkpatch.pl --strict --git d32a863c55ff..77114190bfb4: 0 errors, 0 warnings (859e8a29796c..77114190bfb4: 0 errors, 1 warning for new file test_trusted_refused.py, MAINTAINERS).
  • Earlier at d32a863c55ff: trusted_source KUnit (security/keys/trusted-keys/tests/.kunitconfig, QEMU arm64) 8/9 passed, 1 skipped (trusted_source_after_mark_readonly when built-in).

Every trusted-key seal and unseal on the 13.5 key store first unlocks the
identity key bag (DEVICE_STATE_TRANSITION on the designated user's special
handle). When the enclave answers that unlock with a non-zero status, the
driver logs "ref-key identity unlock refused (status N)" and the seal or
unseal fails with EIO. Nothing outside the kernel log says so, and a
caller cannot tell this from a key store that is still coming up.

On a J313 running the 27.2.1 sepOS the unlock is refused with status -8
on every boot, while the key-store init, LOAD and DESIGNATE still answer.
aurora-sep-load, which cannot see the refusal, retries the seal at 10 Hz
until its 120 s deadline: about 1200 refused seals and kernel warnings per
run, and the unit is started again on every fprintd activation.

Add diag/trusted, which reads:

  unknown      no trusted-key unseal has worked and no unlock was refused
  ready        the latest trusted-key unseal worked (a seal unseals its
               new blob before returning it, so a working seal counts)
  refused <n>  the enclave answered the identity unlock with status <n>

The latest outcome wins, so an unseal that works after a refusal reads
"ready" again, and the value resets to "unknown" when the driver binds.
State and status share one atomic word, so a reader never pairs a state
with another refusal's status. The value comes from the enclave's own
answer: no chip, board or firmware version is consulted, and a Mac whose
enclave unlocks the bag sees only "unknown" and "ready".

Signed-off-by: Erik Bourget <[email protected]>
aurora-sep-load probes trusted keys with a seal and unseal every 0.1 s
until AURORA_SEP_READY_TIMEOUT (120 s). Its only early exit is an xART
guard refusal. When the enclave refuses the identity key-bag unlock that
every seal needs, the probe repeats the same refused request about 1200
times, burns several seconds of CPU and logs a refusal and a
"key_seal failed (-5)" line for each attempt. fprintd's drop-in requires
aurora-sep.service, so every fprintd activation (a desktop shell polls
fprintd-list every few seconds) starts the 120 s run again.

Read the driver's diag/trusted after each failed probe and stop at the
first "refused <status>", logging the status and that the key bag and
ref-key are kept. A run started again in the same boot reads the
attribute before it probes, so it sends no seal at all. An xART guard
refusal is still checked first and keeps its own message, since it has a
way out (aurora-sep-policy-change). Kernels without diag/trusted read
nothing there and keep the old probe-until-deadline behaviour, as do
enclaves that answer late rather than refuse.

The tests run the shipped loader against a synthetic sysfs and a fake
keyctl: the first refusal ends the run after one seal, a re-run sends
none, a guard refusal keeps its message, a kernel without the attribute
still waits for the deadline, and a working enclave still verifies.
They also compile the driver's diag/trusted show and setter and check
all three values, with negative and positive statuses.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 26, 2026 16:37
@erikwb
erikwb requested review from Acelogic and maralcbr November 26, 2026 16:38
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 77114190: not ready yet

Check Detail
CI at head no failing: source, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 77114190
Conflicts ok none
PR text ok Risk: two-way · every Mac with the SEP driver (one whose enclave unlocks the bag or uses the variant-5 key store only ever sees unknown and ready, and its loader path is unchanged)

Areas: area:platform

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

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 26, 2026
sks_prepare_identity_refkey() latches diag/trusted to
"refused <status>" when the enclave refuses the identity key-bag
unlock, so aurora-sep-load stops without retrying for 120 s. A
subsequent successful unlock through /dev/sep-key
(with_identity_bag()) calls sks_prepare_identity_refkey() as well,
without going through refkey_unseal_trusted(), so diag/trusted stayed
"refused <status>" and caused later loader runs to exit before probing.

Add sep_diag_clear_trusted_refusal() and call it from
sks_prepare_identity_refkey() only when the DEVICE_STATE_TRANSITION
reply validates (status 0, 20-byte body with zero header). Using
atomic_try_cmpxchg(), it clears SEP_DIAG_TRUSTED_REFUSED back to
SEP_DIAG_TRUSTED_UNKNOWN while leaving SEP_DIAG_TRUSTED_READY untouched
so "ready" remains tied to a working trusted-key unseal.

Update Documentation/ABI/testing/sysfs-driver-apple-sep and extend
tools/aurora-sep/tests/test_trusted_refused.py and the apple_sep KUnit
tests (apple_sep_refkey_trusted) to cover refusal clearing and recovery.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review findings in 77114190bfb4 and updated the PR description:

  1. Cleared stale diag/trusted refusal on a validated identity unlock (drivers/soc/apple/refkey.rs, drivers/soc/apple/diag.rs, drivers/soc/apple/diag_shim.c, drivers/soc/apple/shim.h, Documentation/ABI/testing/sysfs-driver-apple-sep):

    • sks_prepare_identity_refkey() now calls diag::clear_trusted_refusal() (sep_diag_clear_trusted_refusal()) via record_identity_unlock() when DEVICE_STATE_TRANSITION returns status 0 with a validated 20-byte zero-header body (including unlocks via /dev/sep-key's with_identity_bag()).
    • sep_diag_clear_trusted_refusal() delegates to sep_diag_clear_trusted_refusal_atomic() and uses atomic_try_cmpxchg() to transition SEP_DIAG_TRUSTED_REFUSED back to SEP_DIAG_TRUSTED_UNKNOWN without disturbing SEP_DIAG_TRUSTED_READY, keeping ready tied to a successful trusted-key unseal in refkey_unseal_trusted().
    • Added recovery coverage in tools/aurora-sep/tests/test_trusted_refused.py (8/8 pass, covering sep_diag_clear_trusted_refusal C state transitions and loader re-run recovery after a cleared refusal) and KUnit apple_sep_refkey_trusted (drivers/soc/apple/refkey.rs, 2/2 pass, exercised against a test-owned atomic without modifying live diag/trusted).
  2. PR description cleanup:

    • Replaced the internal kernel build localversion names in the J313 evidence note with baseline main SHA 859e8a29796c and tested head SHA d32a863c55ff.
    • Kept the healthy 13.5 key-store row open under **Not yet:** alongside the variant-5 verification placeholder at 77114190bfb4.

Note on prior CI at d32a863c55ff: the failing checks there were cancelled jobs after 2h31m (Apple build and KUnit run 45860560034 and pr-readiness run 45860560600), while SEP source checks, Host tests, and pr-text passed.

Local verification at 77114190bfb4:

  • drivers/soc/apple/sep.kunitconfig ('apple_sep*', QEMU arm64): 319/319 passed (including apple_sep_refkey_trusted 2/2)
  • tools/asahi/run-host-tests.py --only sep-suspend: 22/22 passed
  • tools/aurora-sep/tests/test_trusted_refused.py: 8/8 passed
  • tools/aurora-sep/tests/test_policy_window.py: 4/4 passed; test_collect_handover.py: 3/3 passed
  • checkpatch.pl --strict --git d32a863c55ff..77114190bfb4: 0 errors, 0 warnings

J313 (M1 Air) at 77114190bfb4 in fleet candidate 5509a254a6bd, with this PR's load-driver installed for the run: diag/protocol sepos13, diag/trusted ready, aurora-sep-load logs trusted keys work after 4 s, 0 key_seal failed lines, graphical.target at about 7 s, diag/trusted stays ready across 2 deep sleeps and an s2idle, 0 failed units, 0 AppArmor denials. The enclave unlocked the identity bag on that boot, so the refused branch was not hit at this head (earlier refused -8 row at d32a863c55ff).

J716c (M5 Max, T6050, variant-5 key store) at 77114190bfb4 in candidate 3e4078f656d5, default command line, with this PR's tools/aurora-sep/load-driver run: diag/protocol reads variant5, diag/trusted reads ready, aurora-sep-load logged trusted keys work after 1 s and /dev/sep-bio is available (rc 0), aurora-sep-ready.service active, 0 new failed units (aurora-peripherals.service and systemd-networkd-wait-online.service pre-existing on default), 0 LSM denials, and 0 SEP kernel errors. The healthy 13.5 key-store row remains under **Not yet:**.

@RyanTheTide

Copy link
Copy Markdown
Contributor

The source check fails on a real build error. shim.h:250 and :252 now use atomic_t, but the host harness compiles diag_shim.c against its own stub headers, which have no atomic_t (tools/aurora-sep/tests/test_diag_policy.py / test_diag_sensor.py, "unknown type name atomic_t"). Add typedef struct { int counter; } atomic_t; (plus the atomic_* helpers the shim calls) to the stub headers those tests write, or include <linux/atomic.h> from shim.h if the stubs already provide it. Then run python3 tools/aurora-sep/tests/test_diag_policy.py locally before the push. Review comes after it is green.

tools/aurora-sep/tests/test_diag_sensor.py compiles diag_shim.c and its
test harnesses against minimal stub kernel headers. In the kernel,
<linux/types.h> defines atomic_t, whereas the test's stub headers
placed the typedef in <linux/atomic.h>. Because drivers/soc/apple/shim.h
includes <linux/types.h> and declares sep_diag_*_atomic(atomic_t *, ...),
harnesses that include "shim.h" without <linux/atomic.h> failed to
compile with "unknown type name 'atomic_t'".

Move `typedef struct { int counter; } atomic_t;` from the stub
linux/atomic.h into the stub linux/types.h so "shim.h" compiles
standalone against the stubs, matching the kernel headers while leaving
all driver and loader files unchanged.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the SEP source checks (source) build failure in 2cdd990f389e.

drivers/soc/apple/shim.h includes <linux/types.h> (which defines atomic_t in the kernel) for its sep_diag_*_atomic(atomic_t *, ...) prototypes, while tools/aurora-sep/tests/test_diag_sensor.py defined typedef struct { int counter; } atomic_t; in its stub linux/atomic.h rather than linux/types.h. Because the HARNESS and GUARD_HARNESS test programs in test_diag_sensor.py include "shim.h" without <linux/atomic.h>, compiling them against the stub headers failed with unknown type name 'atomic_t'.

Moved typedef struct { int counter; } atomic_t; from HEADERS['linux/atomic.h'] into HEADERS['linux/types.h'] in tools/aurora-sep/tests/test_diag_sensor.py (linux/atomic.h retains #include <linux/types.h> and the atomic_* helpers). This keeps all kernel, driver, ABI documentation, and tools/aurora-sep/load-driver files byte-for-byte unchanged from 77114190bfb4.

Verified at 2cdd990f389e:

  • python3 -m unittest tools/aurora-sep/tests/test_diag_policy.py tools/aurora-sep/tests/test_diag_sensor.py -v: 4/4 passed (and 4/4 with python3 -O)
  • python3 -m unittest tools/aurora-sep/tests/test_trusted_refused.py -v: 8/8 passed
  • python3 -I tools/asahi/run-host-tests.py --only sep-suspend: 22/22 passed
  • Remaining sep-source.yml Python unit tests (test_store_open_errors.py, test_identity_preservation.py, test_sep_bio_identities.py, test_orphan_delete.py, test_enrol_admission.py, test_owner_preparation.py, test_policy_window.py, test_log_ratelimit.py, test_key_context_cleanup.py, test_packaging.py, test_sep_writes_always_on.py, test_boot_locks.py, test_kernel_log_anchor.py, test_collect_handover.py, test_touchid_package.py, test_root_staging.py): 120/120 passed
  • ./scripts/checkpatch.pl --strict --git 77114190bfb4..HEAD: 0 errors, 0 warnings, 0 checks

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 2cdd990: merge once CI is green.

Blockers: none. The source fix moves the atomic_t typedef into the stub linux/types.h, and the kernel side is byte-identical to the 7711419 J313 row.

Question (please answer here; it does not block): the loader now stops at the first refused <status> instead of retrying for 120 s. Have you ever seen a refusal on this path turn into a success later in the same boot, for example right after first unlock or after resume? If that never happened in your J313 runs, one line saying so in the body would settle it. If it can happen, keep one bounded retry, a few seconds, before refused_exit.

Checked:

  • diag/trusted is one atomic word: state in the low byte, signed status above it, so a reader never sees a mixed pair. It is reset at bind ("a refusal belongs to the bind that saw it"). Ready is set only by a working unseal; a validated DEVICE_STATE_TRANSITION (20-byte body, zero status) clears only a refusal, through a cmpxchg loop. KUnit covers the short body, a bad status and the clear.
  • Loader: a kernel without the attribute reads empty and keeps the old loop. A re-run this boot (the fprintd dependency) exits at once on a known refusal. The xART guard message still comes first when both apply. The message tells users not to replace the key bag.

@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

On J313 (27.2.1 firmware) a refusal never turned into a success later in the same boot.

  • The baseline (main at 859e8a29796c) retried 905 seals over 119.4 s and none succeeded; it ended with "did not seal and unseal a trusted key within 120 s".
  • With this PR at d32a863c55ff, diag/trusted read refused -8 and stayed refused -8 across a deep sleep (rtcwake -m mem). The earlier row at 12d3f541d9d8 behaved the same.

A later validated DEVICE_STATE_TRANSITION would clear the refusal (record_identity_unlock() in refkey.rs), so a later success is possible in the driver, but I have not seen one. I did not test first unlock or other resume timings beyond the deep sleep above, so I am keeping the loader stop without a bounded retry. The refused branch was not re-run at the final head, because the J313 enclave unlocked the bag there; that is already under **Not yet:**.

@RyanTheTide
RyanTheTide merged commit ff59991 into main Nov 28, 2026
26 of 29 checks passed
@RyanTheTide
RyanTheTide deleted the fix/sep-refused-fastfail branch November 28, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants