summaryrefslogtreecommitdiff
path: root/libs/binder/ProcessState.cpp
Commit message (Collapse)AuthorAgeFilesLines
* binder: fix coverity warningswangmingming12024-02-061-0/+1
| | | | | | | | Bug: None Test: build Change-Id: I7d56bb75c8fe6bb3206855c06959f81335971c4b Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
* Binder unique_fdTomasz Wasilczyk2023-11-171-3/+4
| | | | | | Test: mma Bug: 302723053 Change-Id: I52f14cadb027b3f854946d5315dce3d23aa21b19
* Revert^2 "Use std::unique_ptr instead of ScopeGuard"Tomasz Wasilczyk2023-11-041-2/+4
| | | | | | | | 25c1a3b8543dd1756308424dd65030f90bb7a99f Test: m Bug: 302723053 Change-Id: Id9355c10d78d0c55afb49f512b78bb0923fbc4f7
* Don't depend on libbase result.hTomasz Wasilczyk2023-11-031-23/+22
| | | | | | Test: mma Bug: 302723053 Change-Id: Iea797d6af825d58543ba899f6e712b27e48d859a
* Binder: migrate off libutils MutexTomasz Wasilczyk2023-10-311-4/+4
| | | | | | Bug: 302723053 Test: mma Change-Id: I5b81d5c0b6c7fef7f2216d4010adfa9cf72f9876
* Revert "Use std::unique_ptr instead of ScopeGuard"Sebastian Pickl2023-10-301-4/+2
| | | | | | | | | | | | Revert submission 2780893 Reason for revert: breaking boot tests Bug: 308214260 Reverted changes: /q/submissionid:2780893 Change-Id: I7a4ee9a45583a8a1d4a33447de55c63e6ce9d42a
* Use std::unique_ptr instead of ScopeGuardTomasz Wasilczyk2023-10-271-2/+4
| | | | | | Bug: 302723053 Test: mma Change-Id: I27226885b8b5e771d675ba2d83d0a2e14551d13e
* Use String8/16 c_str [binder]Tomasz Wasilczyk2023-08-251-3/+3
| | | | | | | | | | Current String8::string() has two problems: it may suggest it's returning a std::string and also prevents a drop-in replacement with std::string. Bug: 295394788 Test: make checkbuild Change-Id: I1eb6ddebe3faede57f3e6f046da572a79056125a
* libbinder: thread count startThreadPool spawnSteven Moreland2023-06-151-4/+30
| | | | | | | | | | | When startThreadPool is called, it spawns a thread which is not counted as part of the lazy kernel-started threads. This was discovered in fuzzers, and the test is updated. Bug: 286237215 Test: binderLibTest Change-Id: Ib0fa4484576f9d296b8f57f32ae536b17e5c6497
* libbinder: remove 32-bit ABI supportSteven Moreland2023-04-241-8/+1
| | | | | | | | | | | | | | | This was an old userspace ABI, but we've encouraged all platforms to move to a consistent ABI, regardless of bitness of the device. This corresponds to a kernel config option that we started requiring not be set in Android P. After this, the build system still needs to have this support removed. Bug: 232423610 Test: boot cf Change-Id: Iff5997f910d86c73bbd6502ec393434d248cdcd5
* libbinder: warn when vndbinder use is wastedSteven Moreland2023-02-141-0/+9
| | | | | | | | | | | | | | We can't return null, because there may be other calls in the process to ProcessState, but if vndservicemanager is not installed, we can save a few threads. Note: due to logs being broken (b/210919187) early in boot, you may not be able to see logs for this. Bug: 264617136 Test: check logs, e.g. 02-14 01:31:57.034 3273 3273 E ProcessState: vndservicemanager is not started on this device, you can save resources/threads by not initializing ProcessState with /dev/vndbinder. Change-Id: Ie91dc4ee302e7a36184e533fb755ce0870e2f546
* binder: Add an API to check if the threadpool has been startedDevin Moore2022-12-091-0/+4
| | | | | | | | | Libraries that require the threadpool can check this to make sure the threadpool has been started before it is needed. Test: atest binderLibTest Bug: 261652496 Change-Id: I7505319f162e2789dcc3c41bf1f7535c5c1bb9d9
* libbinder: get threadpool count lockedSteven Moreland2022-07-131-0/+4
| | | | | | | | These variables might be changed by another thread. Bug: 233226955 Test: atest binderLibTest Change-Id: I384f309ed1cc7c062ccc5eaab9f6f6a57142cf7f
* Fix for flaky test in binderLibTestElie Kheirallah2022-05-311-2/+5
| | | | | | | | | Added thread locks around the update of mKernelStartedThreads Added hwasan-presubmit to TEST MAPPING Bug: 233787404 Test: binderLibTest Change-Id: If8dcd7061c478a3ebbb0414c4fcce2a9bf512563
* Merge "Prevent cm from incrementing 0."Treehugger Robot2022-05-201-0/+5
|\
| * Prevent cm from incrementing 0.Steven Moreland2022-05-191-0/+5
| | | | | | | | | | | | | | | | | | The kernel will return an error now when the context manager tries to increment the 0 handle. Bug: 166779391 Test: binderLibTest Change-Id: Iab7af80b491c49c37425e840432d9071f9f36ff4
* | Merge "libbinder: O_CLOFORK"Steven Moreland2022-05-201-0/+4
|\ \ | |/ |/|
| * libbinder: O_CLOFORKSteven Moreland2022-05-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | You can't use binder after forking, so we can drop the FD. The binder driver doesn't support this (once the FD is open, we would need to open a new context in the child process). So, the userspace API would need to handle resetting all state. However, in general, handling this for multi-threaded processes (because of needing to take all locks by all libraries used by all threads and restoring state, etc...) is too complicated to make work in Android. Bug: 232904068 Test: binderLibTest Change-Id: I38c354af2c69804a40dc2774086a9ab77d158ede
* | Merge "Tracking number of threads in threadpools. Added tests for max total ↵Elie Kheirallah2022-05-191-4/+14
|\ \ | |/ |/| | | thread count."
| * Tracking number of threads in threadpools.Elie Kheirallah2022-05-191-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added tests for max total thread count. Renamed getThreadPoolMaxThreadCount to getThreadPoolMaxTotalThreadCount which takes into account user joined threads and polling threads. Test added to check that the current available threads update properly and do not lock. Added second test that simulates a deadlock and confirms the deadlock. Bug: 188834514 Test: binderLibTest Change-Id: Ia99d95544a38596ec9fc316e623e523b64337bc7
* | Merge "Warn about deletion of 32-bit binder IPC ABI."Steven Moreland2022-05-161-0/+5
|\ \ | |/ |/|
| * Warn about deletion of 32-bit binder IPC ABI.Steven Moreland2022-05-131-0/+5
| | | | | | | | | | | | | | | | | | | | No one should be using this, but if they are, we want to know so we can help them move off of this ABI and then eventually delete this code. Bug: 232423610 Test: N/A Change-Id: If8a8f77393cb2df90d1f04b1aea13e2be79f7b38
* | libbinder: add BINDER_GET_EXTENDED_ERROR supportCarlos Llamas2022-05-101-0/+2
|/ | | | | | | | | | | | This adds basic support to pull extended error information provided by the driver via BINDER_GET_EXTENDED_ERROR ioctl. For now, we'll only log the information upon a failed transaction. However, this data can later be used to handle error scenarios such as retry strategies. Bug: 28321379 Test: atest binderLibTest Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: I8aed63cb0d1aa15aa96db4ab8999e300fef1f505
* Revert "Revert "libbinder: Replace deprecated utils/threads.h header""Andrei Homescu2022-03-141-1/+2
| | | | | | | | This reverts commit a643e2dabde445e257dc97e9ce81436497f6b2ee. Reason for revert: Fixed libvrflinger Change-Id: I2df02b571b49fe040958ee2c8236605426315d68
* libbinder: detect features supported by the driverCarlos Llamas2022-03-091-1/+25
| | | | | | | | | | | | | The binder driver exposes the features it supports as individual files under /dev/binderfs/features/*. This patch adds a method to determine whether a feature is enabled or not and avoid unnecessary calls to the driver. In this case, we can skip logging any "oneway spam detection" failures seen during open_driver() if the ioctl is not supported. Bug: 191910201 Tested: toggling driver features manually Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: Ie8e7315cc1ba8baa9cb03bab1fb3bd7507765c99
* Merge "Revert "libbinder: Replace deprecated utils/threads.h header""Treehugger Robot2022-03-091-2/+1
|\
| * Revert "libbinder: Replace deprecated utils/threads.h header"Andrei Homescu2022-03-091-2/+1
| | | | | | | | | | | | | | | | This reverts commit bc8d5b4830d7fb5afe52f9d8809212babedd72b1. Reason for revert: breaks libvrflinger build Change-Id: I767dbf3ed56893ead497184d2204a04156faaa9d
* | Merge changes Id85ddcb6,I3b096848Treehugger Robot2022-03-091-1/+2
|\| | | | | | | | | | | * changes: libbinder: Replace deprecated utils/threads.h header libbinder: Fix PAD_SIZE_UNSAFE
| * libbinder: Replace deprecated utils/threads.h headerAndrei Homescu2022-03-081-1/+2
| | | | | | | | | | | | | | | | | | Replaces the old utils/threads.h with the newer replacement headers or removes it altogether from some files. Bug: None Test: m Change-Id: Id85ddcb6b647e95a649ca2cd77e9db34c5e77b30
* | libbinder: binder thread names ++Steven Moreland2022-02-241-1/+7
|/ | | | | | | | | | | | | As requested by perf team, show domain information first. So, the thread name might look like: binder:3_4 vndbinder:7_8 Fixes: 220391109 Test: boot, ps -AT Change-Id: I70d5d15db01887c01e50cf0b6f656d71ff75d045
* ProcessState: thread name includes driverSteven Moreland2022-02-091-1/+1
| | | | | | | | Disambiguate /dev/binder and /dev/vndbinder thread names. Bug: email thread Test: ps -AT (and see important parts in comm) Change-Id: I898eeb091dba08bb37ffbf8cd9c03f3a21a53c90
* libbinder: remove handle 0 TODOSteven Moreland2022-01-121-5/+0
| | | | | | | | | A different way to do this and needing to support both ways doesn't seem to make this better. Fixes: 168900528 Test: N/A Change-Id: I0f067b6f18a2c47dbc13e00dd692d60bdaf3f639
* libbinder: log when wrong number of threads startSteven Moreland2021-12-161-0/+5
| | | | | | | | | | | Add a log when a service requests to have 0 threads but a threadpool (with a thread) is still requested to be started). This currently doesn't get hit on cuttlefish, but by triggering it manually I can see the log. Bug: 210145621 Test: trigger API misuse case and check for log Change-Id: I9113828e10812895802a83017ed8f55e851fa220
* libbinder: use after fork abortsSteven Moreland2021-10-151-3/+1
| | | | | | | | | This is a separate CL, since the warning is independently useful, even if this needs to be reverted. Fixes: 202289725 Test: binderLibTest Change-Id: Ifb046f01cee047d1908a69c075a66ecb0bc68a78
* libbinder: ProcessState warn on forkedSteven Moreland2021-10-141-2/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reasonably common error, when people's programs are crashing, because libbinder does not support forking (and supporting forking is really complicated and error prone in multithreaded processes: pthread_atfork documentation states this The intent of pthread_atfork() was to provide a mechanism whereby the application (or a library) could ensure that mutexes and other process and thread state would be restored to a consistent state. In practice, this task is generally too difficult to be practicable. specifically, in libbinder, we would have to: - get all of the libbinder-related locks - make sure the kernel driver can handle forking (or open a new binder fd by reinstantiating ProcessState) - (actual difficulty here) make sure we can capture and release application-specific locks - in a multithreaded process, anything could be going on So, we don't want to take on the complexity of supporting it). Instead now, we install a pthread_atfork handler which marks the ProcessState as invalid in the child process. If code tries to access ProcessState after forking, then it will throw an error (future: abort). Note: forking and then using non-binder things, such as what installd and vold does, is okay. Bug: 202289725 Test: boot and check logs (none) Change-Id: I18638a3190ed2ea23945413c2e5ab15d7094d0b0
* Merge changes I89e4de2e,I673d7a4c,Icfb454c2,I5924a82c am: a54c861843Steven Moreland2021-09-141-2/+2
|\ | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1825953 Change-Id: Ibf6c5ced4bc9d9822308c4ab4e370e7290753c39
| * libbinder: hide BpBinder::create(*) functionsSteven Moreland2021-09-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | There is no need to have these around, and having them exposed potentially means they could be stuck in the ABI. They are created (instead of absorbed into the private constructors) because of the additional UID tracking logic there. Bug: 167966510 Test: binderRpcTest Change-Id: I673d7a4c591a1b004f3214e8a17b48e54e91171d
| * libbinder: include full error if cannot initSteven Moreland2021-08-301-49/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've seen a few cases of the "Binder driver could not be opened" error appearing in production, but in most of these contexts, we don't actually have access to the full logs (we only have the tombstone). However, all of the different errors that could happen (running out of FDs, failure to mmap, etc..) would be logged previously. Now, the error is kept, and it is included in the tombstone. Bug: 197637414 (and many others) Test: boot, binderLibTest Test: manually verify error is printed (we don't have an existing test to put this in because ProcessState can only be initialized once): Binder driver '/dev/null' could not be opened. Terminating: Binder ioctl to obtain version failed: Inappropriate ioctl for device Merged-In: I636f1c5bfa9c8932e3db3d84af46ce3b0f1e98bc Change-Id: I636f1c5bfa9c8932e3db3d84af46ce3b0f1e98bc
* | libbinder: include full error if cannot initSteven Moreland2021-08-301-48/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've seen a few cases of the "Binder driver could not be opened" error appearing in production, but in most of these contexts, we don't actually have access to the full logs (we only have the tombstone). However, all of the different errors that could happen (running out of FDs, failure to mmap, etc..) would be logged previously. Now, the error is kept, and it is included in the tombstone. Bug: 197637414 (and many others) Test: boot, binderLibTest Test: manually verify error is printed (we don't have an existing test to put this in because ProcessState can only be initialized once): Binder driver '/dev/null' could not be opened. Terminating: Binder ioctl to obtain version failed: Inappropriate ioctl for device Change-Id: I636f1c5bfa9c8932e3db3d84af46ce3b0f1e98bc
* | Merge sc-dev-plus-aosp-without-vendor@7634622Xin Li2021-08-141-6/+0
|\ \ | |/ |/| | | | | Merged-In: Icec03f01321c64d95d0bf1487ee9a1f4ae10529f Change-Id: I0cc1af993adc6a7e27652d5a3ea481ea582d948c
| * Merge "libbinder: further downgrade oneway spam log" am: 495a84db06 am: ↵Steven Moreland2021-05-251-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | e06865c20f Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1717592 Change-Id: I49863bdfaa135b700d9b42f281191cea8c5a9872
| * \ Merge "Add IBinder::setRpcClient" am: a0b682cc2d am: f15d42920eYifan Hong2021-05-211-0/+8
| |\ \ | | | | | | | | | | | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1683951 Change-Id: Id7711d30da985e5911215727f34a47bb2d61b9a5
| * \ \ Merge changes I6c715612,If84ff928 am: 2281985cd3 am: e5ab8b3709 am: 17078c14b9Steven Moreland2021-05-051-1/+1
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1696388 Change-Id: Ib94c51b4341379912e99cd5d96b741a9cc49f350
| * \ \ \ Merge "Failing to enable oneway spam detection is not an error." am: ↵Steven Moreland2021-04-221-2/+2
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ccd2b60c30 am: 5c84d6004d am: c708616d87 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1683871 Change-Id: I68b40e32ab7a0e88710b4200bb9b800fff1ca0a7
| * \ \ \ \ Merge "libbinder: support BR_ONEWAY_SPAM_SUSPECT" am: 77e3f9fac4 am: ↵Steven Moreland2021-04-211-0/+15
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1964c06663 am: 1fee847987 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1676195 Change-Id: Id49f0e079e058f47381cc154fd96b692b303cadc
| * \ \ \ \ \ Merge "libbinder use stronger refbase semantics" am: d5cc17b3b4 am: ↵Steven Moreland2021-04-121-4/+4
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 374ef9f0eb am: 3d4bed1669 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1664341 Change-Id: Ia3d8cdf2e4664eb4b67a3e21161fdbd03af2c0a7
| * \ \ \ \ \ \ Merge "libbinder: support calls over sockets" am: 4e83ba78f1 am: 32d689ec04 ↵Steven Moreland2021-03-251-1/+3
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 974deb9f13 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1495200 Change-Id: Iab4e34da339d1ac33519efd5aff8b893f5b57d1c
| * | | | | | | | Reland "libbinder: remove __ANDROID_APEX__ stability diff"Steven Moreland2021-02-181-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the product partition is using __ANDROID_VNDK__, we can't remove the __ANDROID_APEX__ check from the NDK header. This reverts commit 15b7029849a1c59ecb54961fa7417ee0611408a0. Reason for revert: reland b/179906909 Fixes: 179906909 Test: the following, which was failing before w/ stability error mmma packages/modules/Gki adb install --staged-ready-timeout 600000\ out/host/linux-x86/testcases/GkiInstallTest/com.android.gki.kmi_5_10_android12_0_test_high.apex Change-Id: I189b5c07ffd767fa46c59fd8828ba4f59b31f095
| * | | | | | | | Revert "libbinder: remove __ANDROID_APEX__ stability diff"Steven Moreland2021-02-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e9441bcf32c04901807748bde85f16444464eb91. Reason for revert: b/180559880#comment7 Bug: 179906909 Change-Id: I04472d3bbe97c9c42df74c10ce87c176fa7098dd
| * | | | | | | | libbinder: remove __ANDROID_APEX__ stability diffSteven Moreland2021-02-171-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were setup because the media APEX module was using vendor variants of libbinder on the system partition. However, now that this build dependency is cleaned up, we can remove the #ifdefs and make this a build error instead of a runtime error. Test: binderStabilityTest Fixes: 179906909 Change-Id: If05cf3fa0851866d7113f6e8f9705891672ad369