summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Kalesh Singh <kaleshsingh@google.com> 2020-12-29 15:46:25 -0500
committer Steven Moreland <smoreland@google.com> 2021-06-03 23:15:03 +0000
commitd67c8e89d2589866f509640bfbac3799c1eca4f8 (patch)
treeba4356daf1d618c0639bf056d6464a51bcd9912e /libs/binder/Parcel.cpp
parent14e4cfae36aa878c6a9838299bc7b9aa42a16dfa (diff)
libbinder: Add binder already sent checks
These operations should only be done before the binder object is sent out to another process: - setRequestingSid - setMinSchedulerPolicy - setInheritRt - setExtension Add log and abort if these are attempted after the binder object has been sent already. Bug: 166282674 Test: binderParcelTest Change-Id: Id2c1d0dc783cad75754a06a3047cf6c7bf704c63
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 10188fee6e..232a70c894 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -196,8 +196,11 @@ static constexpr inline int schedPolicyMask(int policy, int priority) {
return (priority & FLAT_BINDER_FLAG_PRIORITY_MASK) | ((policy & 3) << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT);
}
-status_t Parcel::flattenBinder(const sp<IBinder>& binder)
-{
+status_t Parcel::flattenBinder(const sp<IBinder>& binder) {
+ BBinder* local = nullptr;
+ if (binder) local = binder->localBinder();
+ if (local) local->setParceled();
+
if (isForRpc()) {
if (binder) {
status_t status = writeInt32(1); // non-null
@@ -223,7 +226,6 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder)
}
if (binder != nullptr) {
- BBinder *local = binder->localBinder();
if (!local) {
BpBinder *proxy = binder->remoteBinder();
if (proxy == nullptr) {