Loading libs/binder/Parcel.cpp +330 −204 File changed.Preview size limit exceeded, changes collapsed. Show changes libs/binder/RpcState.cpp +3 −7 Original line number Original line Diff line number Diff line Loading @@ -601,10 +601,8 @@ status_t RpcState::waitForReply(const sp<RpcSession::RpcConnection>& connection, if (rpcReply->status != OK) return rpcReply->status; if (rpcReply->status != OK) return rpcReply->status; data.release(); data.release(); reply->ipcSetDataReference(rpcReply->data, command.bodySize - offsetof(RpcWireReply, data), reply->rpcSetDataReference(session, rpcReply->data, nullptr, 0, cleanup_reply_data); command.bodySize - offsetof(RpcWireReply, data), cleanup_reply_data); reply->markForRpc(session); return OK; return OK; } } Loading Loading @@ -824,11 +822,9 @@ processTransactInternalTailCall: // transaction->data is owned by this function. Parcel borrows this data and // transaction->data is owned by this function. Parcel borrows this data and // only holds onto it for the duration of this function call. Parcel will be // only holds onto it for the duration of this function call. Parcel will be // deleted before the 'transactionData' object. // deleted before the 'transactionData' object. data.ipcSetDataReference(transaction->data, data.rpcSetDataReference(session, transaction->data, transactionData.size() - offsetof(RpcWireTransaction, data), transactionData.size() - offsetof(RpcWireTransaction, data), nullptr /*object*/, 0 /*objectCount*/, do_nothing_to_transact_data); do_nothing_to_transact_data); data.markForRpc(session); if (target) { if (target) { bool origAllowNested = connection->allowNested; bool origAllowNested = connection->allowNested; Loading libs/binder/include/binder/Parcel.h +39 −14 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <map> // for legacy reasons #include <map> // for legacy reasons #include <string> #include <string> #include <type_traits> #include <type_traits> #include <variant> #include <vector> #include <vector> #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> Loading Loading @@ -605,15 +606,19 @@ private: size_t ipcDataSize() const; size_t ipcDataSize() const; uintptr_t ipcObjects() const; uintptr_t ipcObjects() const; size_t ipcObjectsCount() const; size_t ipcObjectsCount() const; void ipcSetDataReference(const uint8_t* data, size_t dataSize, void ipcSetDataReference(const uint8_t* data, size_t dataSize, const binder_size_t* objects, const binder_size_t* objects, size_t objectsCount, size_t objectsCount, release_func relFunc); void rpcSetDataReference(const sp<RpcSession>& session, const uint8_t* data, size_t dataSize, release_func relFunc); release_func relFunc); status_t finishWrite(size_t len); status_t finishWrite(size_t len); void releaseObjects(); void releaseObjects(); void acquireObjects(); void acquireObjects(); status_t growData(size_t len); status_t growData(size_t len); // Clear the Parcel and set the capacity to `desired`. // Doesn't reset the RPC session association. status_t restartWrite(size_t desired); status_t restartWrite(size_t desired); // Set the capacity to `desired`, truncating the Parcel if necessary. status_t continueWrite(size_t desired); status_t continueWrite(size_t desired); status_t writePointer(uintptr_t val); status_t writePointer(uintptr_t val); status_t readPointer(uintptr_t *pArg) const; status_t readPointer(uintptr_t *pArg) const; Loading Loading @@ -1253,18 +1258,39 @@ private: size_t mDataSize; size_t mDataSize; size_t mDataCapacity; size_t mDataCapacity; mutable size_t mDataPos; mutable size_t mDataPos; binder_size_t* mObjects; size_t mObjectsSize; size_t mObjectsCapacity; mutable size_t mNextObjectHint; mutable bool mObjectsSorted; mutable bool mRequestHeaderPresent; // Fields only needed when parcelling for "kernel Binder". struct KernelFields { binder_size_t* mObjects = nullptr; size_t mObjectsSize = 0; size_t mObjectsCapacity = 0; mutable size_t mNextObjectHint = 0; mutable size_t mWorkSourceRequestHeaderPosition; mutable size_t mWorkSourceRequestHeaderPosition = 0; mutable bool mRequestHeaderPresent = false; mutable bool mObjectsSorted = false; mutable bool mFdsKnown = true; mutable bool mHasFds = false; }; // Fields only needed when parcelling for RPC Binder. struct RpcFields { RpcFields(const sp<RpcSession>& session); // Should always be non-null. const sp<RpcSession> mSession; }; std::variant<KernelFields, RpcFields> mVariantFields; // Pointer to KernelFields in mVariantFields if present. KernelFields* maybeKernelFields() { return std::get_if<KernelFields>(&mVariantFields); } const KernelFields* maybeKernelFields() const { return std::get_if<KernelFields>(&mVariantFields); } // Pointer to RpcFields in mVariantFields if present. RpcFields* maybeRpcFields() { return std::get_if<RpcFields>(&mVariantFields); } const RpcFields* maybeRpcFields() const { return std::get_if<RpcFields>(&mVariantFields); } mutable bool mFdsKnown; mutable bool mHasFds; bool mAllowFds; bool mAllowFds; // if this parcelable is involved in a secure transaction, force the // if this parcelable is involved in a secure transaction, force the Loading @@ -1273,7 +1299,6 @@ private: release_func mOwner; release_func mOwner; sp<RpcSession> mSession; size_t mReserved; size_t mReserved; class Blob { class Blob { Loading Loading
libs/binder/Parcel.cpp +330 −204 File changed.Preview size limit exceeded, changes collapsed. Show changes
libs/binder/RpcState.cpp +3 −7 Original line number Original line Diff line number Diff line Loading @@ -601,10 +601,8 @@ status_t RpcState::waitForReply(const sp<RpcSession::RpcConnection>& connection, if (rpcReply->status != OK) return rpcReply->status; if (rpcReply->status != OK) return rpcReply->status; data.release(); data.release(); reply->ipcSetDataReference(rpcReply->data, command.bodySize - offsetof(RpcWireReply, data), reply->rpcSetDataReference(session, rpcReply->data, nullptr, 0, cleanup_reply_data); command.bodySize - offsetof(RpcWireReply, data), cleanup_reply_data); reply->markForRpc(session); return OK; return OK; } } Loading Loading @@ -824,11 +822,9 @@ processTransactInternalTailCall: // transaction->data is owned by this function. Parcel borrows this data and // transaction->data is owned by this function. Parcel borrows this data and // only holds onto it for the duration of this function call. Parcel will be // only holds onto it for the duration of this function call. Parcel will be // deleted before the 'transactionData' object. // deleted before the 'transactionData' object. data.ipcSetDataReference(transaction->data, data.rpcSetDataReference(session, transaction->data, transactionData.size() - offsetof(RpcWireTransaction, data), transactionData.size() - offsetof(RpcWireTransaction, data), nullptr /*object*/, 0 /*objectCount*/, do_nothing_to_transact_data); do_nothing_to_transact_data); data.markForRpc(session); if (target) { if (target) { bool origAllowNested = connection->allowNested; bool origAllowNested = connection->allowNested; Loading
libs/binder/include/binder/Parcel.h +39 −14 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <map> // for legacy reasons #include <map> // for legacy reasons #include <string> #include <string> #include <type_traits> #include <type_traits> #include <variant> #include <vector> #include <vector> #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> Loading Loading @@ -605,15 +606,19 @@ private: size_t ipcDataSize() const; size_t ipcDataSize() const; uintptr_t ipcObjects() const; uintptr_t ipcObjects() const; size_t ipcObjectsCount() const; size_t ipcObjectsCount() const; void ipcSetDataReference(const uint8_t* data, size_t dataSize, void ipcSetDataReference(const uint8_t* data, size_t dataSize, const binder_size_t* objects, const binder_size_t* objects, size_t objectsCount, size_t objectsCount, release_func relFunc); void rpcSetDataReference(const sp<RpcSession>& session, const uint8_t* data, size_t dataSize, release_func relFunc); release_func relFunc); status_t finishWrite(size_t len); status_t finishWrite(size_t len); void releaseObjects(); void releaseObjects(); void acquireObjects(); void acquireObjects(); status_t growData(size_t len); status_t growData(size_t len); // Clear the Parcel and set the capacity to `desired`. // Doesn't reset the RPC session association. status_t restartWrite(size_t desired); status_t restartWrite(size_t desired); // Set the capacity to `desired`, truncating the Parcel if necessary. status_t continueWrite(size_t desired); status_t continueWrite(size_t desired); status_t writePointer(uintptr_t val); status_t writePointer(uintptr_t val); status_t readPointer(uintptr_t *pArg) const; status_t readPointer(uintptr_t *pArg) const; Loading Loading @@ -1253,18 +1258,39 @@ private: size_t mDataSize; size_t mDataSize; size_t mDataCapacity; size_t mDataCapacity; mutable size_t mDataPos; mutable size_t mDataPos; binder_size_t* mObjects; size_t mObjectsSize; size_t mObjectsCapacity; mutable size_t mNextObjectHint; mutable bool mObjectsSorted; mutable bool mRequestHeaderPresent; // Fields only needed when parcelling for "kernel Binder". struct KernelFields { binder_size_t* mObjects = nullptr; size_t mObjectsSize = 0; size_t mObjectsCapacity = 0; mutable size_t mNextObjectHint = 0; mutable size_t mWorkSourceRequestHeaderPosition; mutable size_t mWorkSourceRequestHeaderPosition = 0; mutable bool mRequestHeaderPresent = false; mutable bool mObjectsSorted = false; mutable bool mFdsKnown = true; mutable bool mHasFds = false; }; // Fields only needed when parcelling for RPC Binder. struct RpcFields { RpcFields(const sp<RpcSession>& session); // Should always be non-null. const sp<RpcSession> mSession; }; std::variant<KernelFields, RpcFields> mVariantFields; // Pointer to KernelFields in mVariantFields if present. KernelFields* maybeKernelFields() { return std::get_if<KernelFields>(&mVariantFields); } const KernelFields* maybeKernelFields() const { return std::get_if<KernelFields>(&mVariantFields); } // Pointer to RpcFields in mVariantFields if present. RpcFields* maybeRpcFields() { return std::get_if<RpcFields>(&mVariantFields); } const RpcFields* maybeRpcFields() const { return std::get_if<RpcFields>(&mVariantFields); } mutable bool mFdsKnown; mutable bool mHasFds; bool mAllowFds; bool mAllowFds; // if this parcelable is involved in a secure transaction, force the // if this parcelable is involved in a secure transaction, force the Loading @@ -1273,7 +1299,6 @@ private: release_func mOwner; release_func mOwner; sp<RpcSession> mSession; size_t mReserved; size_t mReserved; class Blob { class Blob { Loading