Repository navigation
soc: apple: sep: open the host-state store only for each operation - #583
Merged
RyanTheTide merged 1 commit intoNov 9, 2026
Conversation
Store::open() opens /var/lib/aurora-sep-host-state.bin read-write, and the store keeps the file open until the driver goes away, in practice until power-off. The driver opens it from the kernel, so no task holds it, and killing every process at shutdown does not close it. The file system it lives on can then be neither unmounted nor remounted read-only: every poweroff logs Failed to unmount /persist: Device or resource busy and the file system stays mounted read-write until the machine powers off. This hits any setup where the store is not on the root file system, such as an impermanent root that keeps /var/lib state on a /persist file system through a symlink. Keep the slot table in memory as before, and open the file only to load it, to read a record and for each write, closing it when the operation returns. The write sequence and the on-disk format do not change. The keybag, ref-key and catacomb files are already opened per use, and the xART store is a block device under /dev. Store is now generic over a StoreSource that opens the backing file. An open StoreIo that is Copy is its own source, so the KUnit tests keep using their in-memory files unchanged. Fixes: 24d20c9 ("soc: apple: add Apple SEP driver (Touch ID and key sealing)") Assisted-by: LLM Signed-off-by: Andrzej Broński <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Nov 9, 2026
jgoyvaerts
added a commit
to jgoyvaerts/linux
that referenced
this pull request
Nov 9, 2026
The xART guard opens /var/lib/aurora-sep-xart-owned.bin read-write when the xART store is set up and keeps it in the guard, which lives as long as the store: until the device is unbound. Nothing unbinds it before a reboot, so the kernel holds a writer on the file system that holds /var/lib until power-off. systemd-shutdown's read-only remount of that file system then fails with EBUSY and it stays read-write. The host-state store has the same problem, and aurora-silicon#583 fixes that one. Both files have to be closed before the file system unmounts cleanly: on a J616s with the host-state store fixed, the root still was not remounted read-only at shutdown, and every boot still replayed the ext4 journal. Open the list for each access instead: read-only for size, reads and syncs, existing-only for writes. Only Guard::open() creates it. The create-and-adopt rule in with_file() is unchanged: the directory is still flushed before a list is adopted. The list format and the KUnit tests, which use an in-memory file, are unchanged. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
koxu1996
added a commit
to koxu1996/nixos-config
that referenced
this pull request
Nov 16, 2026
aurora-silicon/linux#583 was merged into integration/aurora (Linux 7.3), not feat/sep, which this kernel is pinned to; the patch stays until the pin moves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a NixOS install with an impermanent root (ZFS, rolled back at every boot), every poweroff logs
Failed to unmount /persist: Device or resource busy. The cause is the SEP driver: it keeps/var/lib/aurora-sep-host-state.binopen read-write from the kernel until power-off. This opens it only while it is being used.What happened
store::Store::open()opens the host-state file once at probe, andStoreholds that file inhost_storefor the driver's lifetime. The open comes from the kernel, so no process owns it, and killing every process at shutdown does not close it.On this machine
/var/lib/aurora-sep-host-state.binis a symlink into/persist, where all persistent state lives. A final-shutdown hook captured the following:/persistread-only failed withEBUSY, which happens while a file is open for writing.EBUSYtoo, and still failed 1 s and 3 s later./persiststayed mounted read-write until power-off.The keybag, ref-key and catacomb files are already opened per use, and the xART store is a block device under
/dev. So the host-state store is the only file that stays open.Anything that keeps
/var/liboff the root file system is affected the same way: a separate/varor/var/lib, or impermanence setups like this one.The change (
store.rsonly)Storekeeps the slot table and generation in memory as before, but no longer holds the file.store_shipped.rsand the compatibility tests are unaffected.Storeis generic over a smallStoreSourcethat opens the backing file. Production usesHostFile(STORE_PATHviaopen_host). An openStoreIothat isCopyis its own source, so the KUnit tests keep using&MemoryFilewithout changes.from_fileis now only used by the tests, so it is#[cfg(CONFIG_APPLE_SEP_KUNIT_TEST)]. Production loads throughStore::open(), which reuses the fileopen_hostjust opened.Tested
/persist. Runningfeat/sepat 120e030 (7.1.9) with the same change made to the olderstore.rs:/persistnow unmounts at poweroff; theEBUSYfrom before is gone.apple-sep.kobuilds withCONFIG_APPLE_SEP_KUNIT_TEST=yand no warnings (rustc 1.99).