Repository navigation
fix(daemon): prevent circular binder recursion in SystemServerService - #1114
Open
ludicious-claw wants to merge 1 commit into
Open
ludicious-claw wants to merge 1 commit into
ludicious-claw wants to merge 1 commit into
Conversation
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.
Summary of Changes
This PR fixes a critical crash in
vectordcaused by infinite Binder transaction recursion and stack overflow (SIGSEGV (SEGV_ACCERR)inJavaBBinder::onTransact).Root Cause Analysis
On Android 16 (BP2A) and newer OEM builds (reproduced on Vivo OriginOS, device
PD2352), whenSystemServerServiceis registered inServiceManager, theIServiceCallback.onRegistrationcallback fires and notifies the daemon.Self-referential
BinderProxyadoption:In
SystemServerService.adoptOriginService(name, binder), the guard check was:However, the incoming
binderpassed by the Binder framework during registration callback is an instance ofandroid.os.BinderProxy, not the localSystemServerService(Binder) instance. Therefore,binder === thisevaluates tofalse, andoriginServicewas mistakenly set to a proxy targetingSystemServerServiceitself.Unconditional transaction forwarding:
In
SystemServerService.onTransact, incoming transactions were forwarded tooriginServicebefore checking the transaction code:When
system_server(via Zygisk) invokedBRIDGE_TRANSACTION_CODE, the transaction was intercepted and forwarded tooriginService(which pointed right back toSystemServerService), creating a recursive loop on the same Binder thread until the stack overflowed the guard page (~500 recursive calls).Fix
DESCRIPTOR = "org.matrix.vector.daemon.ipc.SystemServerService"and implementedgetInterfaceDescriptor().adoptOriginServiceto reject adoption ifbinder === thisorbinder.interfaceDescriptor == DESCRIPTOR.originService?.transact(...)forwarding from the top ofonTransactinto theelsebranch ofwhen (code).BRIDGE_TRANSACTION_CODE,DEX_TRANSACTION_CODE,OBFUSCATION_MAP_TRANSACTION_CODE) are strictly processed locally and never forwarded.Verification
:daemon:ktfmtFormat../gradlew :daemon:assembleRelease.