Repository navigation
KEYS: trusted: keep a trusted-key source that registers before init_trusted() - #350
Merged
Merged
Conversation
Add KUnit tests for register_trusted_key_source() and unregister_trusted_key_source(), with a synthetic source that touches no hardware and no real key material. They cover dispatch to the source and back to the absent stubs when it withdraws, the migration policy that each registration brings (a key update included), a second source being refused and unable to withdraw the first, a failing init(), and incomplete sources. Built in, KUnit runs before mark_readonly(), so one case, which registers with read-only-after-init data protected, skips there and says so. Loaded as a module after boot, as apple_sep is, the whole suite runs that way. [ryan: on 7.1 'migratable' is still writable, so registration after mark_readonly() cannot fault here. The case guards against a backport of the v7.2 change that makes it read-only after init.] Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A trusted-key source module that is built in registers from its probe: apple_sep with CONFIG_APPLE_SEP=y probes at device_initcall, before init_trusted() runs at late_initcall. init_trusted() then looks for a built-in source, finds none, and points the dispatch at the absent stubs, without taking the source mutex or checking for a registered source. That source still holds the slot, so nothing can take it again. Every new trusted key now fails with -ENODEV after registration was logged as a success, and the key type stays registered. A modular apple_sep loads after init_trusted() and is not affected. Mainline chooses the source once, in init_trusted(). Keep it that way, and have init_trusted() defer: under the source mutex, it leaves the slot and the dispatch to a source that is already active, and otherwise chooses as before. Whichever source comes up first keeps the slot, and a later one still gets -EBUSY; trusted.source= and trusted.rng= are checked on both paths, as before. The choice moves into trusted_key_core_init(), which the KUnit tests call with synthetic sources, in both orders: a source that registers before the core's init keeps the slot and its migration policy, and one that registers after it replaces the absent stubs. Fixes: bac0846 ("soc: apple: add Apple SEP driver (Touch ID and key sealing)") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #6 assembly, stacked on top-up #5 f34b5ae so that it is a fast-forward of the published branch. The second parent is that canonical assembly; the tree is identical to it. Ported from aurora-wip, each with cherry-pick -x and its original author: - #347 KUNIT_ALL_TESTS=m modpost (3): the xHCI platform tests call the interrupt handler through the HC driver (170-usb), and module descriptions for the CD321x PM tests (170-usb) and the drm/apple KUnit test modules (200-dcp). - #349 the CD321x IRQ test waits for the resume read before checking its retry (170-usb). - #350 trusted keys keep a source that registers before init_trusted() (100-sep). Its test commit is already carried as 76d70cc and is not duplicated. - #351 SEP hwrng: recover the entropy exchange after a request times out, and hold entropy requests while the system sleeps (100-sep). - #352 SEP SBIO: take a reply header only once it has landed, and poison it again once read and before each host send (100-sep). Adaptations, each with a [ryan: ...] note in its commit: - trusted-type.h: context only, the declaration goes above the 7.2.10 CONFIG_TRUSTED_KEYS_DEBUG block; - the CD321x IRQ test takes its data from tipd_hw_variants[], and its retry loop replaces the 7.2.10-only fix of the same race in 11e0ce6. The Co-Authored-By lines of the three #347 commits are dropped. Assisted-by: LLM Signed-off-by: Ryan Murray <[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.
If
apple_sepis built in (CONFIG_APPLE_SEP=y), it registers its trusted-key source from probe atdevice_initcall.init_trusted()runs later, atlate_initcall, finds no built-in source, and resets the static-call dispatch to the absent stubs. It does that without taking the source lock and without checking for a registered source. The source still holds the slot, soadd_key trusted "new 32"then fails with-ENODEV, even though "source registered" was logged. The shipped Neo config buildsapple_sepas a module (=m), so it isn't affected. A built-in build is: for example, the linux-aurora package's shared config asks forAPPLE_SEP=y.Fix (2 commits)
trusted_source, which uses a synthetic source with no hardware and no real keys.Fixes: bac0846c9087).trusted_key_core_init(), undertrusted_key_source_lock.-EBUSY, andtrusted.source=/trusted.rng=are checked on both paths.trusted_source_before_core_initandtrusted_source_after_core_init.Testing
trusted_source7/7 plus 1 skip. The built-in order was also reproduced and checked end to end in QEMU, on both 7.1 and 7.2.10.7.1.12-aurora-sepfix-g598fa89b(aurora-wip545d7e45+ this + soc: apple: sep: hold hwrng requests across system sleep and recover a timed-out entropy exchange #351's SEP fixes):trusted_key: source 'applesep' registered;EPERM;KUNIT_ALL_TESTS=mmodpost is clean.🤖 Generated with Claude Code