Repository navigation
Conversation
sep_bio_unregister() and the release of the last open file each decide, under d->lock, whether they are the last user, and the one that is frees d right after its own mutex_unlock(). But the other side may still be inside mutex_unlock(&d->lock): the unlock slow path takes the wait lock and wakes waiters after the lock has been handed over, and a spinning waiter can take the mutex, finish, and free d in that window. The mutex documentation forbids freeing the memory a mutex lives in while another task may still be in its unlock. Count one reference for the registration and one per open file, and drop it after each side's unlock has returned. The side that drops the last reference frees d, so nobody can still be inside d's mutex then. misc_deregister() runs before the registration reference is dropped, so no open can race with the final put. Checked by reading the open, release, ioctl, poll and unregister paths. Not built as a kernel module or run on hardware; the race itself is too narrow to show on this host. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
The "import <hex-key>" command was added for the Apple SEP source, but the trusted-key core accepts it for every source: TPM, TEE, CAAM, DCP and PKWM. Upstream has no such command. With it, root can make a TPM- or TEE-sealed "trusted" key whose plaintext was chosen and seen in userspace, which breaks what consumers of trusted keys (encrypted keys' "trusted:" master key, dm-crypt key descriptions) expect: that the plaintext was made in the kernel. Refuse "import" before the source is called unless all of these hold: - The kernel is built with the new CONFIG_TRUSTED_KEYS_IMPORT. It is off by default, like CONFIG_USER_DECRYPTED_DATA for encrypted keys. Without it, "import" fails with -EINVAL. - The active source sets the new "importable" flag in struct trusted_key_ops, next to "migratable". The core records the flag when a source becomes active (built in or registered at runtime) and clears it when the source withdraws. The upstream sources leave it at 0, so for them "import" is refused as upstream refuses an unknown command. The SEP source sets it. - The kernel is not locked down for integrity: security_locked_down(LOCKDOWN_INTEGRITY_MAX) is checked, and its error (-EPERM) returned. No Aurora tool uses "import", and arch/arm64/configs/asahi.config does not turn the option on. The KUnit case trusted_source_import checks that import fails with -EINVAL and seals nothing for a source without the flag, that a source with the flag seals exactly when CONFIG_TRUSTED_KEYS_IMPORT is set, and that import fails again once that source has withdrawn. The lockdown check has no KUnit case: a test cannot lock the kernel down and undo it. Verified: a host copy of the command parse shows "import" refused without the flag and accepted with it. The kernel C code and the KUnit case were not compiled or run here. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
The SEP trusted-key source ignored everything after the command: "new 32 blobauth=..." or "load <blob> pcrinfo=..." made or loaded a key as if the option were absent. A caller who asks for a blob password or a PCR binding gets a key without that protection and no error. The TPM source would have applied the option. Refuse any option after the command with -EINVAL in the shim's seal and unseal trampolines, before the Rust callback runs. Trailing white space still passes, so "new 32 " and a blob with a trailing newline work as before. The in-tree users (tools/aurora-sep/load-driver and the coordinator runtime check) pass no options. Verified: a host C harness (clang, ASan and UBSan) that mirrors the core's strsep() parse gives 0 for "new 32", "new 32 \t\n" and "load abcd\n", and -EINVAL for blobauth=, keyauth=, pcrinfo= and migratable= after new, load or import. The kernel code was not compiled here. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
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.
Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which). This carries RyanTheTide's two requests on the trusted-keys commit.
Summary
No Aurora tool sends
import, andasahi.configleaves the option off.Evidence
trusted_sourceon arm64 QEMU, withCONFIG_TRUSTED_KEYS_IMPORToff and on:passed, Apple build and KUnit.
trusted_source_importchecks that a source without the flag never seals,that a source with it seals only when the option is set, and that a withdrawn source leaves
nothing behind. Each run: 9 of 10 passed and 1 skipped (
trusted_source_after_mark_readonly,which cannot run in a built-in kernel). SEP source checks: passed, SEP source checks.
process releases it, and creating and loading a trusted key with the SEP source.
Merge Danger
Door: two-way
Blast Radius: trusted keys
importstops working unless the kernel is built with the new option. Nothing in the tree uses it.Assisted-by: LLM (Claude:Opus 5.5)