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

Commit fdc7d1cb authored by Dmitriy Filchenko (xWF)'s avatar Dmitriy Filchenko (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Trusty Binder: split large messages in RpcTransportTipcAndroid" into main

parents 63fcfa09 406b9c97
Loading
Loading
Loading
Loading
+26 −1
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ public:
            const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds) override {
            const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds) override {
        bool sentFds = false;
        bool sentFds = false;
        auto writeFn = [&](iovec* iovs, size_t niovs) -> ssize_t {
        auto writeFn = [&](iovec* iovs, size_t niovs) -> ssize_t {
            // Collect the ancillary FDs.
            trusty_shm shms[kMaxTipcHandles] = {{0}};
            trusty_shm shms[kMaxTipcHandles] = {{0}};
            ssize_t shm_count = 0;
            ssize_t shm_count = 0;


@@ -100,9 +101,33 @@ public:
                }
                }
            }
            }


            auto ret = TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovs,
            // Trusty currently has a message size limit, which will go away once we
            // switch to vsock. The message is reassembled on the receiving side.
            static const size_t maxMsgSize = VIRTIO_VSOCK_MSG_SIZE_LIMIT;
            size_t niovsMsg;
            size_t currSize = 0;
            size_t cutSize = 0;
            for (niovsMsg = 0; niovsMsg < niovs; niovsMsg++) {
                if (__builtin_add_overflow(currSize, iovs[niovsMsg].iov_len, &currSize)) {
                    ALOGE("%s: iov_len add_overflow", __FUNCTION__);
                    return NO_MEMORY;
                }
                if (currSize >= maxMsgSize) {
                    // Truncate the last iov but restore it at the end
                    // so the caller can continue where we left off.
                    cutSize = currSize - maxMsgSize;
                    iovs[niovsMsg].iov_len -= cutSize;
                    niovsMsg++;
                    break;
                }
            }

            auto ret = TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovsMsg,
                                                    (shm_count == 0) ? nullptr : shms, shm_count));
                                                    (shm_count == 0) ? nullptr : shms, shm_count));
            sentFds |= ret >= 0;
            sentFds |= ret >= 0;
            if (niovsMsg > 0) {
                iovs[niovsMsg - 1].iov_len += cutSize;
            }
            return ret;
            return ret;
        };
        };


+1 −1
Original line number Original line Diff line number Diff line
@@ -65,7 +65,7 @@ RpcServerTrusty::RpcServerTrusty(std::unique_ptr<RpcTransportCtx> ctx, std::stri
        mPortAcl(std::move(portAcl)) {
        mPortAcl(std::move(portAcl)) {
    mTipcPort.name = mPortName.c_str();
    mTipcPort.name = mPortName.c_str();
    mTipcPort.msg_max_size = msgMaxSize;
    mTipcPort.msg_max_size = msgMaxSize;
    mTipcPort.msg_queue_len = 6; // Three each way
    mTipcPort.msg_queue_len = 16;
    mTipcPort.priv = this;
    mTipcPort.priv = this;


    if (mPortAcl) {
    if (mPortAcl) {