Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9b876b0 authored by Shubang Lu's avatar Shubang Lu Committed by Automerger Merge Worker
Browse files

Revert "libbinder: binder RPC - using getCalling* aborts" am: 009a6872

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14604507

Change-Id: Ib7d5867a03ec185654a5038778ce4297b34ff8b6
parents 3cebe386 009a6872
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@

#include "RpcState.h"

#include <android-base/scopeguard.h>
#include <binder/BpBinder.h>
#include <binder/IPCThreadState.h>
#include <binder/RpcServer.h>

#include "Debug.h"
@@ -30,8 +28,6 @@

namespace android {

using base::ScopeGuard;

RpcState::RpcState() {}
RpcState::~RpcState() {}

@@ -474,18 +470,6 @@ 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{"processing binder RPC command"};
    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);
+0 −2
Original line number Diff line number Diff line
@@ -55,6 +55,4 @@ interface IBinderRpcTest {
    oneway void sleepMsAsync(int ms);

    void die(boolean cleanup);

    void useKernelBinderCallingId();
}
+0 −21
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <android/binder_libbinder.h>
#include <binder/Binder.h>
#include <binder/BpBinder.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <binder/RpcServer.h>
@@ -192,13 +191,6 @@ public:
            _exit(1);
        }
    }
    Status useKernelBinderCallingId() override {
        // this is WRONG! It does not make sense when using RPC binder, and
        // because it is SO wrong, and so much code calls this, it should abort!

        (void)IPCThreadState::self()->getCallingPid();
        return Status::ok();
    }
};
sp<IBinder> MyBinderRpcTest::mHeldBinder;

@@ -895,19 +887,6 @@ TEST_P(BinderRpc, Die) {
    }
}

TEST_P(BinderRpc, UseKernelBinderCallingId) {
    auto proc = createRpcTestSocketServerProcess(1);

    // we can't allocate IPCThreadState so actually the first time should
    // succeed :(
    EXPECT_OK(proc.rootIface->useKernelBinderCallingId());

    // second time! we catch the error :)
    EXPECT_EQ(DEAD_OBJECT, proc.rootIface->useKernelBinderCallingId().transactionError());

    proc.expectInvalid = true;
}

TEST_P(BinderRpc, WorksWithLibbinderNdkPing) {
    auto proc = createRpcTestSocketServerProcess(1);