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

Commit b86e26b7 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: RPC skip init on /dev/null

This started breaking the fuzzer, since we can't do a socket operation
on /dev/null.

Bug: N/A # yet!
Test: fuzzer no longer crashes
Change-Id: I881f63b85108ff488cb5798b1f0b96629b592329
parent 01a6bad2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ void RpcServer::establishConnection(sp<RpcServer>&& server, base::unique_fd clie
        }

        if (reverse) {
            LOG_ALWAYS_FATAL_IF(!session->addOutgoingConnection(std::move(clientFd)),
            LOG_ALWAYS_FATAL_IF(!session->addOutgoingConnection(std::move(clientFd), true),
                                "server state must already be initialized");
            return;
        }
+7 −4
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ bool RpcSession::addNullDebuggingClient() {
        return false;
    }

    return addOutgoingConnection(std::move(serverFd));
    return addOutgoingConnection(std::move(serverFd), false);
}

sp<IBinder> RpcSession::getRootObject() {
@@ -432,7 +432,7 @@ bool RpcSession::setupOneSocketConnection(const RpcSocketAddress& addr, const Rp
            LOG_ALWAYS_FATAL_IF(!ownershipTransferred);
            return true;
        } else {
            return addOutgoingConnection(std::move(serverFd));
            return addOutgoingConnection(std::move(serverFd), true);
        }
    }

@@ -440,7 +440,7 @@ bool RpcSession::setupOneSocketConnection(const RpcSocketAddress& addr, const Rp
    return false;
}

bool RpcSession::addOutgoingConnection(unique_fd fd) {
bool RpcSession::addOutgoingConnection(unique_fd fd, bool init) {
    sp<RpcConnection> connection = sp<RpcConnection>::make();
    {
        std::lock_guard<std::mutex> _l(mMutex);
@@ -458,7 +458,10 @@ bool RpcSession::addOutgoingConnection(unique_fd fd) {
        mOutgoingConnections.push_back(connection);
    }

    status_t status = mState->sendConnectionInit(connection, sp<RpcSession>::fromExisting(this));
    status_t status = OK;
    if (init) {
        mState->sendConnectionInit(connection, sp<RpcSession>::fromExisting(this));
    }

    {
        std::lock_guard<std::mutex> _l(mMutex);
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ private:
    [[nodiscard]] bool setupSocketClient(const RpcSocketAddress& address);
    [[nodiscard]] bool setupOneSocketConnection(const RpcSocketAddress& address,
                                                const RpcAddress& sessionId, bool server);
    [[nodiscard]] bool addOutgoingConnection(base::unique_fd fd);
    [[nodiscard]] bool addOutgoingConnection(base::unique_fd fd, bool init);
    [[nodiscard]] bool setForServer(const wp<RpcServer>& server,
                                    const wp<RpcSession::EventListener>& eventListener,
                                    const RpcAddress& sessionId);