Loading libs/binder/BpBinder.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -214,16 +214,21 @@ status_t BpBinder::transact( { // 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; } } Loading libs/binder/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ { "name": "binderSafeInterfaceTest" }, { "name": "binderVendorDoubleLoadTest" }, { "name": "binderDriverInterfaceTest" }, Loading libs/binder/include/binder/IBinder.h +5 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,11 @@ public: 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(); Loading libs/binder/ndk/ibinder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -542,7 +543,8 @@ binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, APa 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; } Loading libs/binder/ndk/include_platform/android/binder_stability.h +18 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading @@ -35,6 +49,10 @@ static inline void AIBinder_markCompilationUnitStability(AIBinder* binder) { #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. */ Loading Loading
libs/binder/BpBinder.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -214,16 +214,21 @@ status_t BpBinder::transact( { // 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; } } Loading
libs/binder/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ { "name": "binderSafeInterfaceTest" }, { "name": "binderVendorDoubleLoadTest" }, { "name": "binderDriverInterfaceTest" }, Loading
libs/binder/include/binder/IBinder.h +5 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,11 @@ public: 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(); Loading
libs/binder/ndk/ibinder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -542,7 +543,8 @@ binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, APa 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; } Loading
libs/binder/ndk/include_platform/android/binder_stability.h +18 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading @@ -35,6 +49,10 @@ static inline void AIBinder_markCompilationUnitStability(AIBinder* binder) { #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. */ Loading