summaryrefslogtreecommitdiff
path: root/libs/binder/RpcState.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2025-01-28 01:02:15 +0000
committer Steven Moreland <smoreland@google.com> 2025-01-28 16:22:03 -0800
commit54fa6c72a903905b388ea8193cd2ffcf5abeb8bf (patch)
treeaf5fc06df9949387b79f0efa361469ff5c0cb044 /libs/binder/RpcState.cpp
parenta5f7d9f7b8db227c0d72664394513ed58fe38b59 (diff)
RPC Binder: increase transaction size
One of the RPC Binder usecases requires a larger transaction limit. This change increases the limit, and it unifies the 'too large transaction' logging from regular and RPC binder. This hopefully makes it more clear why there is a limit there, we want to keep code compatible between the two transports. A test is added to show the current behavior. When a transaction which is sent is too large, the server closes the session. This is probably the correct behavior for too large replies, but for too large transactions, the client could handle these errors. b/392717039 is filed to investigate inconsistencies raised in the test more deeply. Fixes: 392575419 Test: atest binderRpcTest --test-filter="*LargeVector*" Change-Id: I2eeb08818c10371c7f77a35abee7d4e46bb63d72
Diffstat (limited to 'libs/binder/RpcState.cpp')
-rw-r--r--libs/binder/RpcState.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index fe6e1a3318..03d974d186 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -23,6 +23,7 @@
#include <binder/IPCThreadState.h>
#include <binder/RpcServer.h>
+#include "Constants.h"
#include "Debug.h"
#include "RpcWireFormat.h"
#include "Utils.h"
@@ -337,6 +338,8 @@ std::string RpcState::BinderNode::toString() const {
}
RpcState::CommandData::CommandData(size_t size) : mSize(size) {
+ if (size == 0) return;
+
// The maximum size for regular binder is 1MB for all concurrent
// transactions. A very small proportion of transactions are even
// larger than a page, but we need to avoid allocating too much
@@ -348,11 +351,11 @@ RpcState::CommandData::CommandData(size_t size) : mSize(size) {
// transaction (in some cases, additional fixed size amounts are added),
// though for rough consistency, we should avoid cases where this data type
// is used for multiple dynamic allocations for a single transaction.
- constexpr size_t kMaxTransactionAllocation = 100 * 1000;
- if (size == 0) return;
- if (size > kMaxTransactionAllocation) {
- ALOGW("Transaction requested too much data allocation %zu", size);
+ if (size > binder::kRpcTransactionLimitBytes) {
+ ALOGE("Transaction requested too much data allocation: %zu bytes, failing.", size);
return;
+ } else if (size > binder::kLogTransactionsOverBytes) {
+ ALOGW("Transaction too large: inefficient and in danger of breaking: %zu bytes.", size);
}
mData.reset(new (std::nothrow) uint8_t[size]);
}