libbinder_ndk: fix vendor<->vendor transactions.
Before, BpBinder was blocking these since kLocalStability was always
vendor.
Fixes: 142658240
Test: binderVendorDoubleLoadTest
Change-Id: I898a76fc35ed6a15e783b53e925ec47877790b7c
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 50c7053..238c9dc 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -214,16 +214,21 @@
{
// Once a binder has died, it will never come back to life.
if (mAlive) {
+ bool privateVendor = flags & FLAG_PRIVATE_VENDOR;
+ // don't send userspace flags to the kernel
+ flags = flags & ~FLAG_PRIVATE_VENDOR;
+
// user transactions require a given stability level
if (code >= FIRST_CALL_TRANSACTION && code <= LAST_CALL_TRANSACTION) {
using android::internal::Stability;
auto stability = Stability::get(this);
+ auto required = privateVendor ? Stability::VENDOR : Stability::kLocalStability;
- if (CC_UNLIKELY(!Stability::check(stability, Stability::kLocalStability))) {
+ if (CC_UNLIKELY(!Stability::check(stability, required))) {
ALOGE("Cannot do a user transaction on a %s binder in a %s context.",
Stability::stabilityString(stability).c_str(),
- Stability::stabilityString(Stability::kLocalStability).c_str());
+ Stability::stabilityString(required).c_str());
return BAD_TYPE;
}
}
diff --git a/libs/binder/include/binder/IBinder.h b/libs/binder/include/binder/IBinder.h
index 64f3052..64604b7 100644
--- a/libs/binder/include/binder/IBinder.h
+++ b/libs/binder/include/binder/IBinder.h
@@ -62,7 +62,11 @@
DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'),
// Corresponds to TF_ONE_WAY -- an asynchronous call.
- FLAG_ONEWAY = 0x00000001
+ FLAG_ONEWAY = 0x00000001,
+
+ // Private userspace flag for transaction which is being requested from
+ // a vendor context.
+ FLAG_PRIVATE_VENDOR = 0x10000000,
};
IBinder();
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp
index b06ca86..e752c45 100644
--- a/libs/binder/ndk/ibinder.cpp
+++ b/libs/binder/ndk/ibinder.cpp
@@ -17,6 +17,7 @@
#include <android/binder_ibinder.h>
#include "ibinder_internal.h"
+#include <android/binder_stability.h>
#include <android/binder_status.h>
#include "parcel_internal.h"
#include "status_internal.h"
@@ -542,7 +543,8 @@
return STATUS_UNKNOWN_TRANSACTION;
}
- if ((flags & ~FLAG_ONEWAY) != 0) {
+ constexpr binder_flags_t kAllFlags = FLAG_PRIVATE_VENDOR | FLAG_ONEWAY;
+ if ((flags & ~kAllFlags) != 0) {
LOG(ERROR) << __func__ << ": Unrecognized flags sent: " << flags;
return STATUS_BAD_VALUE;
}
diff --git a/libs/binder/ndk/include_platform/android/binder_stability.h b/libs/binder/ndk/include_platform/android/binder_stability.h
index 924812e..2a4ded8 100644
--- a/libs/binder/ndk/include_platform/android/binder_stability.h
+++ b/libs/binder/ndk/include_platform/android/binder_stability.h
@@ -20,9 +20,23 @@
__BEGIN_DECLS
+/**
+ * Private addition to binder_flag_t.
+ */
+enum {
+ /**
+ * Indicates that this transaction is coupled w/ vendor.img
+ */
+ FLAG_PRIVATE_VENDOR = 0x10000000,
+};
+
#if defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || \
(defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__))
+enum {
+ FLAG_PRIVATE_LOCAL = FLAG_PRIVATE_VENDOR,
+};
+
/**
* This interface has the stability of the vendor image.
*/
@@ -35,6 +49,10 @@
#else // defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || (defined(__ANDROID_VNDK__) &&
// !defined(__ANDROID_APEX__))
+enum {
+ FLAG_PRIVATE_LOCAL = 0,
+};
+
/**
* This interface has the stability of the system image.
*/