Loading libs/binder/IPCThreadState.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ static const char *kReturnStrings[] = { "BR_DEAD_BINDER", "BR_CLEAR_DEATH_NOTIFICATION_DONE", "BR_FAILED_REPLY", "BR_FROZEN_REPLY", "BR_ONEWAY_SPAM_SUSPECT", "BR_TRANSACTION_SEC_CTX", }; Loading Loading @@ -894,6 +896,11 @@ status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) } switch (cmd) { case BR_ONEWAY_SPAM_SUSPECT: ALOGE("Process seems to be sending too many oneway calls."); CallStack::logStack("oneway spamming", CallStack::getCurrent().get(), ANDROID_LOG_ERROR); [[fallthrough]]; case BR_TRANSACTION_COMPLETE: if (!reply && !acquireResult) goto finish; break; Loading libs/binder/ProcessState.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ #define BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2) #define DEFAULT_MAX_BINDER_THREADS 15 #define DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION 1 #ifdef __ANDROID_VNDK__ const char* kDefaultDriver = "/dev/vndbinder"; Loading Loading @@ -358,6 +359,15 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { return result; } status_t ProcessState::enableOnewaySpamDetection(bool enable) { uint32_t enableDetection = enable ? 1 : 0; if (ioctl(mDriverFD, BINDER_ENABLE_ONEWAY_SPAM_DETECTION, &enableDetection) == -1) { ALOGE("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno)); return -errno; } return NO_ERROR; } void ProcessState::giveThreadPoolName() { androidSetThreadName( makeBinderThreadName().string() ); } Loading Loading @@ -388,6 +398,11 @@ static int open_driver(const char *driver) if (result == -1) { ALOGE("Binder ioctl to set max threads failed: %s", strerror(errno)); } uint32_t enable = DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION; result = ioctl(fd, BINDER_ENABLE_ONEWAY_SPAM_DETECTION, &enable); if (result == -1) { ALOGE("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno)); } } else { ALOGW("Opening '%s' failed: %s\n", driver, strerror(errno)); } Loading libs/binder/include/binder/ProcessState.h +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ public: void spawnPooledThread(bool isMain); status_t setThreadPoolMaxThreadCount(size_t maxThreads); status_t enableOnewaySpamDetection(bool enable); void giveThreadPoolName(); String8 getDriverName(); Loading libs/binder/include/private/binder/binder_module.h +13 −7 Original line number Diff line number Diff line Loading @@ -32,10 +32,6 @@ #include <sys/ioctl.h> #include <linux/android/binder.h> #ifdef __cplusplus namespace android { #endif #ifndef BR_FROZEN_REPLY // Temporary definition of BR_FROZEN_REPLY. For production // this will come from UAPI binder.h Loading Loading @@ -88,8 +84,18 @@ struct binder_frozen_status_info { }; #endif //BINDER_GET_FROZEN_INFO #ifdef __cplusplus } // namespace android #endif #ifndef BR_ONEWAY_SPAM_SUSPECT // Temporary definition of BR_ONEWAY_SPAM_SUSPECT. For production // this will come from UAPI binder.h #define BR_ONEWAY_SPAM_SUSPECT _IO('r', 19) #endif //BR_ONEWAY_SPAM_SUSPECT #ifndef BINDER_ENABLE_ONEWAY_SPAM_DETECTION /* * Temporary definitions for oneway spam detection support. For the final version * these will be defined in the UAPI binder.h file from upstream kernel. */ #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) #endif //BINDER_ENABLE_ONEWAY_SPAM_DETECTION #endif // _BINDER_MODULE_H_ Loading
libs/binder/IPCThreadState.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ static const char *kReturnStrings[] = { "BR_DEAD_BINDER", "BR_CLEAR_DEATH_NOTIFICATION_DONE", "BR_FAILED_REPLY", "BR_FROZEN_REPLY", "BR_ONEWAY_SPAM_SUSPECT", "BR_TRANSACTION_SEC_CTX", }; Loading Loading @@ -894,6 +896,11 @@ status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) } switch (cmd) { case BR_ONEWAY_SPAM_SUSPECT: ALOGE("Process seems to be sending too many oneway calls."); CallStack::logStack("oneway spamming", CallStack::getCurrent().get(), ANDROID_LOG_ERROR); [[fallthrough]]; case BR_TRANSACTION_COMPLETE: if (!reply && !acquireResult) goto finish; break; Loading
libs/binder/ProcessState.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ #define BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2) #define DEFAULT_MAX_BINDER_THREADS 15 #define DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION 1 #ifdef __ANDROID_VNDK__ const char* kDefaultDriver = "/dev/vndbinder"; Loading Loading @@ -358,6 +359,15 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { return result; } status_t ProcessState::enableOnewaySpamDetection(bool enable) { uint32_t enableDetection = enable ? 1 : 0; if (ioctl(mDriverFD, BINDER_ENABLE_ONEWAY_SPAM_DETECTION, &enableDetection) == -1) { ALOGE("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno)); return -errno; } return NO_ERROR; } void ProcessState::giveThreadPoolName() { androidSetThreadName( makeBinderThreadName().string() ); } Loading Loading @@ -388,6 +398,11 @@ static int open_driver(const char *driver) if (result == -1) { ALOGE("Binder ioctl to set max threads failed: %s", strerror(errno)); } uint32_t enable = DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION; result = ioctl(fd, BINDER_ENABLE_ONEWAY_SPAM_DETECTION, &enable); if (result == -1) { ALOGE("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno)); } } else { ALOGW("Opening '%s' failed: %s\n", driver, strerror(errno)); } Loading
libs/binder/include/binder/ProcessState.h +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ public: void spawnPooledThread(bool isMain); status_t setThreadPoolMaxThreadCount(size_t maxThreads); status_t enableOnewaySpamDetection(bool enable); void giveThreadPoolName(); String8 getDriverName(); Loading
libs/binder/include/private/binder/binder_module.h +13 −7 Original line number Diff line number Diff line Loading @@ -32,10 +32,6 @@ #include <sys/ioctl.h> #include <linux/android/binder.h> #ifdef __cplusplus namespace android { #endif #ifndef BR_FROZEN_REPLY // Temporary definition of BR_FROZEN_REPLY. For production // this will come from UAPI binder.h Loading Loading @@ -88,8 +84,18 @@ struct binder_frozen_status_info { }; #endif //BINDER_GET_FROZEN_INFO #ifdef __cplusplus } // namespace android #endif #ifndef BR_ONEWAY_SPAM_SUSPECT // Temporary definition of BR_ONEWAY_SPAM_SUSPECT. For production // this will come from UAPI binder.h #define BR_ONEWAY_SPAM_SUSPECT _IO('r', 19) #endif //BR_ONEWAY_SPAM_SUSPECT #ifndef BINDER_ENABLE_ONEWAY_SPAM_DETECTION /* * Temporary definitions for oneway spam detection support. For the final version * these will be defined in the UAPI binder.h file from upstream kernel. */ #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) #endif //BINDER_ENABLE_ONEWAY_SPAM_DETECTION #endif // _BINDER_MODULE_H_