diff options
| author | 2021-04-21 17:28:29 +0000 | |
|---|---|---|
| committer | 2021-04-21 17:28:29 +0000 | |
| commit | 1fee8479874466db2cbadfd9ae3d610efc6d3931 (patch) | |
| tree | 007e9793876614514662a01e8d19e105a9c27c7f /libs/binder/ProcessState.cpp | |
| parent | 1b1e2be723fc728b6ff16e49ff8a36557348c883 (diff) | |
| parent | 1964c066637f70f0b58bcc4dbbc4461e1664446a (diff) | |
Merge "libbinder: support BR_ONEWAY_SPAM_SUSPECT" am: 77e3f9fac4 am: 1964c06663
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1676195
Change-Id: Ib06376a8958eb78729c35c15be8a8a31f42353be
Diffstat (limited to 'libs/binder/ProcessState.cpp')
| -rw-r--r-- | libs/binder/ProcessState.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index a8b2fb2ff8..ca99042342 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -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"; @@ -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() ); } @@ -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)); } |