Loading libs/binder/Binder.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,6 @@ status_t BBinder::transact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { data.setDataPosition(0); data.setTransactingBinder(this); status_t err = NO_ERROR; switch (code) { Loading @@ -139,7 +138,6 @@ status_t BBinder::transact( // In case this is being transacted on in the same process. if (reply != nullptr) { reply->setDataPosition(0); reply->setTransactingBinder(this); } return err; Loading libs/binder/BpBinder.cpp +12 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <binder/IPCThreadState.h> #include <binder/IResultReceiver.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/Log.h> Loading Loading @@ -213,14 +214,21 @@ status_t BpBinder::transact( { // Once a binder has died, it will never come back to life. if (mAlive) { // 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); if (CC_UNLIKELY(!Stability::check(stability, Stability::kLocalStability))) { return BAD_TYPE; } } status_t status = IPCThreadState::self()->transact( mHandle, code, data, reply, flags); if (status == DEAD_OBJECT) mAlive = 0; if (reply != nullptr) { reply->setTransactingBinder(this); } return status; } Loading libs/binder/Parcel.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <binder/IPCThreadState.h> #include <binder/Parcel.h> #include <binder/ProcessState.h> #include <binder/Stability.h> #include <binder/Status.h> #include <binder/TextOutput.h> Loading Loading @@ -170,11 +171,10 @@ static void release_object(const sp<ProcessState>& proc, status_t Parcel::finishFlattenBinder( const sp<IBinder>& binder, const flat_binder_object& flat) { internal::Stability::tryMarkCompilationUnit(binder.get()); status_t status = writeObject(flat, false); if (status != OK) return status; internal::Stability::tryMarkCompilationUnit(binder.get()); return writeInt32(internal::Stability::get(binder.get())); } Loading @@ -185,10 +185,6 @@ status_t Parcel::finishUnflattenBinder( status_t status = readInt32(&stability); if (status != OK) return status; if (binder != nullptr && !internal::Stability::check(stability, mRequiredStability)) { return BAD_TYPE; } status = internal::Stability::set(binder.get(), stability, true /*log*/); if (status != OK) return status; Loading Loading @@ -356,10 +352,6 @@ status_t Parcel::setDataCapacity(size_t size) return NO_ERROR; } void Parcel::setTransactingBinder(const sp<IBinder>& binder) const { mRequiredStability = internal::Stability::get(binder.get()); } status_t Parcel::setData(const uint8_t* buffer, size_t len) { if (len > INT32_MAX) { Loading Loading @@ -2705,10 +2697,9 @@ void Parcel::initState() mObjectsCapacity = 0; mNextObjectHint = 0; mObjectsSorted = false; mAllowFds = true; mHasFds = false; mFdsKnown = true; mRequiredStability = internal::Stability::UNDECLARED; mAllowFds = true; mOwner = nullptr; mOpenAshmemSize = 0; mWorkSourceRequestHeaderPosition = 0; Loading libs/binder/ProcessState.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <binder/BpBinder.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Stability.h> #include <cutils/atomic.h> #include <utils/Log.h> #include <utils/String8.h> Loading Loading @@ -109,7 +110,13 @@ sp<ProcessState> ProcessState::selfOrNull() sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& /*caller*/) { return getStrongProxyForHandle(0); sp<IBinder> context = getStrongProxyForHandle(0); // The root object is special since we get it directly from the driver, it is never // written by Parcell::writeStrongBinder. internal::Stability::tryMarkCompilationUnit(context.get()); return context; } void ProcessState::startThreadPool() Loading libs/binder/Stability.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -32,6 +32,11 @@ void Stability::debugLogStability(const std::string& tag, const sp<IBinder>& bin ALOGE("%s: stability is %s", tag.c_str(), stabilityString(get(binder.get())).c_str()); } void Stability::markVndk(IBinder* binder) { status_t result = set(binder, Level::VENDOR, true /*log*/); LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object."); } void Stability::tryMarkCompilationUnit(IBinder* binder) { (void) set(binder, kLocalStability, false /*log*/); } Loading Loading @@ -95,9 +100,9 @@ bool Stability::check(int32_t provided, Level required) { } if (!stable) { ALOGE("Interface with %s cannot accept interface with %s.", stabilityString(required).c_str(), stabilityString(provided).c_str()); ALOGE("Cannot do a user transaction on a %s binder in a %s context.", stabilityString(provided).c_str(), stabilityString(required).c_str()); } return stable; Loading Loading
libs/binder/Binder.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,6 @@ status_t BBinder::transact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { data.setDataPosition(0); data.setTransactingBinder(this); status_t err = NO_ERROR; switch (code) { Loading @@ -139,7 +138,6 @@ status_t BBinder::transact( // In case this is being transacted on in the same process. if (reply != nullptr) { reply->setDataPosition(0); reply->setTransactingBinder(this); } return err; Loading
libs/binder/BpBinder.cpp +12 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <binder/IPCThreadState.h> #include <binder/IResultReceiver.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/Log.h> Loading Loading @@ -213,14 +214,21 @@ status_t BpBinder::transact( { // Once a binder has died, it will never come back to life. if (mAlive) { // 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); if (CC_UNLIKELY(!Stability::check(stability, Stability::kLocalStability))) { return BAD_TYPE; } } status_t status = IPCThreadState::self()->transact( mHandle, code, data, reply, flags); if (status == DEAD_OBJECT) mAlive = 0; if (reply != nullptr) { reply->setTransactingBinder(this); } return status; } Loading
libs/binder/Parcel.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <binder/IPCThreadState.h> #include <binder/Parcel.h> #include <binder/ProcessState.h> #include <binder/Stability.h> #include <binder/Status.h> #include <binder/TextOutput.h> Loading Loading @@ -170,11 +171,10 @@ static void release_object(const sp<ProcessState>& proc, status_t Parcel::finishFlattenBinder( const sp<IBinder>& binder, const flat_binder_object& flat) { internal::Stability::tryMarkCompilationUnit(binder.get()); status_t status = writeObject(flat, false); if (status != OK) return status; internal::Stability::tryMarkCompilationUnit(binder.get()); return writeInt32(internal::Stability::get(binder.get())); } Loading @@ -185,10 +185,6 @@ status_t Parcel::finishUnflattenBinder( status_t status = readInt32(&stability); if (status != OK) return status; if (binder != nullptr && !internal::Stability::check(stability, mRequiredStability)) { return BAD_TYPE; } status = internal::Stability::set(binder.get(), stability, true /*log*/); if (status != OK) return status; Loading Loading @@ -356,10 +352,6 @@ status_t Parcel::setDataCapacity(size_t size) return NO_ERROR; } void Parcel::setTransactingBinder(const sp<IBinder>& binder) const { mRequiredStability = internal::Stability::get(binder.get()); } status_t Parcel::setData(const uint8_t* buffer, size_t len) { if (len > INT32_MAX) { Loading Loading @@ -2705,10 +2697,9 @@ void Parcel::initState() mObjectsCapacity = 0; mNextObjectHint = 0; mObjectsSorted = false; mAllowFds = true; mHasFds = false; mFdsKnown = true; mRequiredStability = internal::Stability::UNDECLARED; mAllowFds = true; mOwner = nullptr; mOpenAshmemSize = 0; mWorkSourceRequestHeaderPosition = 0; Loading
libs/binder/ProcessState.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <binder/BpBinder.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Stability.h> #include <cutils/atomic.h> #include <utils/Log.h> #include <utils/String8.h> Loading Loading @@ -109,7 +110,13 @@ sp<ProcessState> ProcessState::selfOrNull() sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& /*caller*/) { return getStrongProxyForHandle(0); sp<IBinder> context = getStrongProxyForHandle(0); // The root object is special since we get it directly from the driver, it is never // written by Parcell::writeStrongBinder. internal::Stability::tryMarkCompilationUnit(context.get()); return context; } void ProcessState::startThreadPool() Loading
libs/binder/Stability.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -32,6 +32,11 @@ void Stability::debugLogStability(const std::string& tag, const sp<IBinder>& bin ALOGE("%s: stability is %s", tag.c_str(), stabilityString(get(binder.get())).c_str()); } void Stability::markVndk(IBinder* binder) { status_t result = set(binder, Level::VENDOR, true /*log*/); LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object."); } void Stability::tryMarkCompilationUnit(IBinder* binder) { (void) set(binder, kLocalStability, false /*log*/); } Loading Loading @@ -95,9 +100,9 @@ bool Stability::check(int32_t provided, Level required) { } if (!stable) { ALOGE("Interface with %s cannot accept interface with %s.", stabilityString(required).c_str(), stabilityString(provided).c_str()); ALOGE("Cannot do a user transaction on a %s binder in a %s context.", stabilityString(provided).c_str(), stabilityString(required).c_str()); } return stable; Loading