summaryrefslogtreecommitdiff
path: root/libs/binder/IPCThreadState.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2022-09-13 00:35:24 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-09-13 00:35:24 +0000
commite14ff5c8724321df896abb64ba1e0bf4c0c3f7a7 (patch)
treec354ee945b33e047575a84705dec0b079a1d8dde /libs/binder/IPCThreadState.cpp
parent1206ba64a63ba4e2eacdd24e1eaf7911823a87b4 (diff)
parent245dff1ff81ddf4c6f0617fa20585f9e248b630d (diff)
Merge "libbinder: fix buffer free race" am: c6fc862bf0 am: 245dff1ff8
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2210443 Change-Id: I64e77badef3cc9a6ce2c81a6533053e61d725622 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs/binder/IPCThreadState.cpp')
-rw-r--r--libs/binder/IPCThreadState.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index b50cfb3d19..bfcf39ad30 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -1318,6 +1318,13 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
LOG_ONEWAY("Sending reply to %d!", mCallingPid);
if (error < NO_ERROR) reply.setError(error);
+ // b/238777741: clear buffer before we send the reply.
+ // Otherwise, there is a race where the client may
+ // receive the reply and send another transaction
+ // here and the space used by this transaction won't
+ // be freed for the client.
+ buffer.setDataSize(0);
+
constexpr uint32_t kForwardReplyFlags = TF_CLEAR_BUF;
sendReply(reply, (tr.flags & kForwardReplyFlags));
} else {