summaryrefslogtreecommitdiff
path: root/libs/binder/IPCThreadState.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2022-09-12 23:37:02 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-09-12 23:37:02 +0000
commitc6fc862bf0bd0f1f6ec0dee0e6b9913cbae9bb9f (patch)
treec354ee945b33e047575a84705dec0b079a1d8dde /libs/binder/IPCThreadState.cpp
parent796287c6e71c0a72a982708cf72adb27b9c800c1 (diff)
parentce15b9fc8930edb034938afd972d1f2e3fd1974c (diff)
Merge "libbinder: fix buffer free race"
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 {