Repository navigation
ASoC: macaudio: keep the speaker route while protection is granted - #1017
Merged
Merged
Conversation
"Speaker Playback Mux" picks the front-end that drives the speakers. The owner of "Speaker Protection" grants playback for the front-end its protection engine runs on, but the mux stays writable by any user of the card. On the MCA machines (J316, J413, J274, J293, J313 and their siblings) both front-ends are real PCMs, so a write under a running grant routes the other one, which carries no protection, to the amps. The owner notices on its next check of the route and withdraws, but until then that stream plays at the granted operating point. Refuse writes to the speaker mux with -EBUSY while protection is granted. Before a grant the route may change as before: the owner checks it before it grants. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
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.
"Speaker Playback Mux" picks the front-end that drives the speakers. Any user of the card can still write it while speakerguardd v2 holds a protection grant. On the MCA machines (J316, J413 and the M1 boards) both front-ends are real PCMs, so the write routes the other front-end, which has no protection in its path, to the amps at the granted operating point.
The supervisor already catches this on its next tick (it checks the route every 10 ms and withdraws on a mismatch), so the exposure is at most one tick, or one lease if the supervisor is dead. This closes it in the kernel: the mux refuses writes with
-EBUSYwhile protection is granted. Before a grant the route can still change as before, because the owner checks the route before it grants. The self-check's route change happens before its grant, and the J616s/J713 front-end layout is unaffected.Found by the speakerguardd v2 safety audit.
Tests (buildbox,
kunit.py run --arch=arm64 LLVM=1, macaudio suites): 45/45 passed, including two new cases:macaudio_route_is_protected: only the speaker mux gets the check, the headphone mux doesn't.macaudio_route_fixed_while_granted: writable unowned and owned,-EBUSYwhile granted, writable again after release and after the owner closes.checkpatch: 0 errors, 0 warnings.
🤖 Generated with Claude Code