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

Commit 5f498ab7 authored by Steven Moreland's avatar Steven Moreland
Browse files

RPC Binder: shutdown on ENOMEM

We were expecting crashes in these case, but explicitly
shut down. More work needs to be done to ignore transactions
in out of memory conditions.

Bug: 404210068
Bug: 414720799
Bug: 416734088
Test: binderRpcTest
Change-Id: Iaf9a34b4031fb7b9807c962bcc67de8cd9102088
Merged-In: Iaf9a34b4031fb7b9807c962bcc67de8cd9102088
(cherry picked from commit cba4e364)
parent e7626987
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -656,7 +656,13 @@ status_t RpcState::waitForReply(const sp<RpcSession::RpcConnection>& connection,
    memset(&rpcReply, 0, sizeof(RpcWireReply)); // zero because of potential short read
    memset(&rpcReply, 0, sizeof(RpcWireReply)); // zero because of potential short read


    CommandData data(command.bodySize - rpcReplyWireSize);
    CommandData data(command.bodySize - rpcReplyWireSize);
    if (!data.valid()) return NO_MEMORY;
    if (!data.valid()) {
        // b/404210068 - if we run out of memory, the wire protocol gets messed up.
        // so shutdown. We would need to read all the transaction data anyway and
        // send a reply still to gracefully recover.
        (void)session->shutdownAndWait(false);
        return NO_MEMORY;
    }


    iovec iovs[]{
    iovec iovs[]{
            {&rpcReply, rpcReplyWireSize},
            {&rpcReply, rpcReplyWireSize},
@@ -813,6 +819,10 @@ status_t RpcState::processTransact(


    CommandData transactionData(command.bodySize);
    CommandData transactionData(command.bodySize);
    if (!transactionData.valid()) {
    if (!transactionData.valid()) {
        // b/404210068 - if we run out of memory, the wire protocol gets messed up.
        // so shutdown. We would need to read all the transaction data anyway and
        // send a reply still to gracefully recover.
        (void)session->shutdownAndWait(false);
        return NO_MEMORY;
        return NO_MEMORY;
    }
    }
    iovec iov{transactionData.data(), transactionData.size()};
    iovec iov{transactionData.data(), transactionData.size()};