diff options
author | 2021-05-15 01:32:04 +0000 | |
---|---|---|
committer | 2021-05-18 00:37:29 +0000 | |
commit | d73020787e8730575b91bb010f0895571887970b (patch) | |
tree | 8f49da981b4f59f50922a843cde952babe69ffd1 /libs/binder/RpcState.cpp | |
parent | 35626658834a9b4edcb47a09ca8b7e33d65c2e10 (diff) |
Revert^2 "libbinder: binder RPC - using getCalling* aborts"
15e2835588ce3a8e318c01230bda2c113a16f761
Broken code? Now you know!
Fixes: 186647790
Test: binderRpcTest (on host and device)
Change-Id: I994b007b76d68771519dc8279534616ec60e9d71
Diffstat (limited to 'libs/binder/RpcState.cpp')
-rw-r--r-- | libs/binder/RpcState.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 2ba9fa2bd5..230de6f0ef 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -18,7 +18,9 @@ #include "RpcState.h" +#include <android-base/scopeguard.h> #include <binder/BpBinder.h> +#include <binder/IPCThreadState.h> #include <binder/RpcServer.h> #include "Debug.h" @@ -28,6 +30,8 @@ namespace android { +using base::ScopeGuard; + RpcState::RpcState() {} RpcState::~RpcState() {} @@ -470,6 +474,21 @@ status_t RpcState::getAndExecuteCommand(const base::unique_fd& fd, const sp<RpcS status_t RpcState::processServerCommand(const base::unique_fd& fd, const sp<RpcSession>& session, const RpcWireHeader& command) { + IPCThreadState* kernelBinderState = IPCThreadState::selfOrNull(); + IPCThreadState::SpGuard spGuard{ + .address = __builtin_frame_address(0), + .context = "processing binder RPC command", + }; + const IPCThreadState::SpGuard* origGuard; + if (kernelBinderState != nullptr) { + origGuard = kernelBinderState->pushGetCallingSpGuard(&spGuard); + } + ScopeGuard guardUnguard = [&]() { + if (kernelBinderState != nullptr) { + kernelBinderState->restoreGetCallingSpGuard(origGuard); + } + }; + switch (command.command) { case RPC_COMMAND_TRANSACT: return processTransact(fd, session, command); |