Loading libs/binder/BpBinder.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -160,11 +160,12 @@ void BpBinder::ObjectManager::kill() // --------------------------------------------------------------------------- sp<BpBinder> BpBinder::create(int32_t handle) { sp<BpBinder> BpBinder::create(int32_t handle, std::function<void()>* postTask) { if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); return nullptr; } LOG_ALWAYS_FATAL_IF(postTask == nullptr, "BAD STATE"); int32_t trackedUid = -1; if (sCountByUidEnabled) { Loading @@ -183,7 +184,11 @@ sp<BpBinder> BpBinder::create(int32_t handle) { ALOGE("Still too many binder proxy objects sent to uid %d from uid %d (%d proxies " "held)", getuid(), trackedUid, trackedValue); if (sLimitCallback) sLimitCallback(trackedUid); if (sLimitCallback) { *postTask = [=]() { sLimitCallback(trackedUid); }; } sLastLimitCallbackMap[trackedUid] = trackedValue; } } else { Loading @@ -197,7 +202,11 @@ sp<BpBinder> BpBinder::create(int32_t handle) { ALOGE("Too many binder proxy objects sent to uid %d from uid %d (%d proxies held)", getuid(), trackedUid, trackedValue); sTrackingMap[trackedUid] |= LIMIT_REACHED_MASK; if (sLimitCallback) sLimitCallback(trackedUid); if (sLimitCallback) { *postTask = [=]() { sLimitCallback(trackedUid); }; } sLastLimitCallbackMap[trackedUid] = trackedValue & COUNTING_VALUE_MASK; if (sBinderProxyThrottleCreate) { ALOGI("Throttling binder proxy creates from uid %d in uid %d until binder proxy" Loading libs/binder/ProcessState.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -310,6 +310,7 @@ extern sp<BBinder> the_context_object; sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) { sp<IBinder> result; std::function<void()> postTask; std::unique_lock<std::mutex> _l(mLock); Loading Loading @@ -357,7 +358,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) return nullptr; } sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle); sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle, &postTask); e->binder = b.get(); if (b) e->refs = b->getWeakRefs(); result = b; Loading @@ -370,6 +371,10 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) } } _l.unlock(); if (postTask) postTask(); return result; } Loading libs/binder/include/binder/BpBinder.h +4 −2 Original line number Diff line number Diff line Loading @@ -134,7 +134,9 @@ public: friend class ::android::RpcState; explicit PrivateAccessor(const BpBinder* binder) : mBinder(binder) {} static sp<BpBinder> create(int32_t handle) { return BpBinder::create(handle); } static sp<BpBinder> create(int32_t handle, std::function<void()>* postTask) { return BpBinder::create(handle, postTask); } static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address) { return BpBinder::create(session, address); } Loading @@ -156,7 +158,7 @@ private: friend PrivateAccessor; friend class sp<BpBinder>; static sp<BpBinder> create(int32_t handle); static sp<BpBinder> create(int32_t handle, std::function<void()>* postTask); static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address); struct BinderHandle { Loading Loading
libs/binder/BpBinder.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -160,11 +160,12 @@ void BpBinder::ObjectManager::kill() // --------------------------------------------------------------------------- sp<BpBinder> BpBinder::create(int32_t handle) { sp<BpBinder> BpBinder::create(int32_t handle, std::function<void()>* postTask) { if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); return nullptr; } LOG_ALWAYS_FATAL_IF(postTask == nullptr, "BAD STATE"); int32_t trackedUid = -1; if (sCountByUidEnabled) { Loading @@ -183,7 +184,11 @@ sp<BpBinder> BpBinder::create(int32_t handle) { ALOGE("Still too many binder proxy objects sent to uid %d from uid %d (%d proxies " "held)", getuid(), trackedUid, trackedValue); if (sLimitCallback) sLimitCallback(trackedUid); if (sLimitCallback) { *postTask = [=]() { sLimitCallback(trackedUid); }; } sLastLimitCallbackMap[trackedUid] = trackedValue; } } else { Loading @@ -197,7 +202,11 @@ sp<BpBinder> BpBinder::create(int32_t handle) { ALOGE("Too many binder proxy objects sent to uid %d from uid %d (%d proxies held)", getuid(), trackedUid, trackedValue); sTrackingMap[trackedUid] |= LIMIT_REACHED_MASK; if (sLimitCallback) sLimitCallback(trackedUid); if (sLimitCallback) { *postTask = [=]() { sLimitCallback(trackedUid); }; } sLastLimitCallbackMap[trackedUid] = trackedValue & COUNTING_VALUE_MASK; if (sBinderProxyThrottleCreate) { ALOGI("Throttling binder proxy creates from uid %d in uid %d until binder proxy" Loading
libs/binder/ProcessState.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -310,6 +310,7 @@ extern sp<BBinder> the_context_object; sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) { sp<IBinder> result; std::function<void()> postTask; std::unique_lock<std::mutex> _l(mLock); Loading Loading @@ -357,7 +358,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) return nullptr; } sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle); sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle, &postTask); e->binder = b.get(); if (b) e->refs = b->getWeakRefs(); result = b; Loading @@ -370,6 +371,10 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) } } _l.unlock(); if (postTask) postTask(); return result; } Loading
libs/binder/include/binder/BpBinder.h +4 −2 Original line number Diff line number Diff line Loading @@ -134,7 +134,9 @@ public: friend class ::android::RpcState; explicit PrivateAccessor(const BpBinder* binder) : mBinder(binder) {} static sp<BpBinder> create(int32_t handle) { return BpBinder::create(handle); } static sp<BpBinder> create(int32_t handle, std::function<void()>* postTask) { return BpBinder::create(handle, postTask); } static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address) { return BpBinder::create(session, address); } Loading @@ -156,7 +158,7 @@ private: friend PrivateAccessor; friend class sp<BpBinder>; static sp<BpBinder> create(int32_t handle); static sp<BpBinder> create(int32_t handle, std::function<void()>* postTask); static sp<BpBinder> create(const sp<RpcSession>& session, uint64_t address); struct BinderHandle { Loading