summaryrefslogtreecommitdiff
path: root/libs/binder/RpcState.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Binder unique_fdTomasz Wasilczyk2023-11-171-14/+14
| | | | | | Test: mma Bug: 302723053 Change-Id: I52f14cadb027b3f854946d5315dce3d23aa21b19
* Revert^2 "Use std::function instead of base::function_ref"Tomasz Wasilczyk2023-11-041-18/+17
| | | | | | | | 84b7cff1a7082d32e9043014e57db7b4ed2aa7a0 Test: m Bug: 302723053 Change-Id: If25bdb65254a4a8ad5afeda7e6ce1eedf422d896
* Revert^2 "Use std::unique_ptr instead of ScopeGuard"Tomasz Wasilczyk2023-11-041-3/+5
| | | | | | | | 25c1a3b8543dd1756308424dd65030f90bb7a99f Test: m Bug: 302723053 Change-Id: Id9355c10d78d0c55afb49f512b78bb0923fbc4f7
* Binder: migrate off libbase macrosTomasz Wasilczyk2023-11-031-5/+4
| | | | | | Test: mma Bug: 302723053 Change-Id: Ie7c13c324311f600d72bc8ecc4157ad6c46259a0
* RPC Binder: limit experimental wire protocol useSteven Moreland2023-10-301-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | Only allow experimental wire protocol when: - we're on Android - it's not a release build This is intended to avoid things in the wild accidentally freezing the experimental wire protocol. If such a thing happened, we'd have to stop using the existing experimental wire protocol version and increment it. Worse though, it may de facto freeze the experimental version at that time, or even cause RPC binder to fail in certain cases. One downside of this is that when we make changes to the RPC binder wire protocol, that we would no longer be able to test it. In order to avoid that problem, we could add another way to enable it at that time. However, to play things on the safe side, disabling by default for now. Fixes: 305983144 Test: binderRpcTest Change-Id: Ieb23cc11d6f3c5b77545dcfd7621f1464dd98f0f
* Migrate off of base::StringPrintfTomasz Wasilczyk2023-10-251-15/+18
| | | | | | Bug: 302723053 Test: mma Change-Id: Id7f0b1d0a11747a5a61a2550f05d7caaabf339a3
* Merge "binderRpcTest: conditional experimental protocol" into mainSteven Moreland2023-10-171-1/+2
|\
| * binderRpcTest: conditional experimental protocolSteven Moreland2023-10-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | Previously this test failed in REL mode and required a change. This was done so that we made sure to freeze it for release. Now that we have TARGET_RELEASE, we need to make this conditional. Bug: 305786304 Test: binderRpcTest on '-next' configuration Change-Id: I726c71399c7e469698abc630a006ce089dc4bca8
* | Copy HexString to libbinderTomasz Wasilczyk2023-10-121-3/+2
|/ | | | | | Bug: 302723053 Test: mma Change-Id: I5c7a71a91b7dc95bfa0cd653eabe554bdd3f7812
* Make sure to handle new RpcSession::FileDescriptorTransportModeTomasz Wasilczyk2023-06-281-0/+1
| | | | | | Bug: 289151149 Test: binder_rpc_test Change-Id: I0944e94e52219c6f040c304f50e70a16f5ae25cd
* RPC binder: limit experimental wire protocol usageSteven Moreland2023-05-311-2/+19
| | | | | | | | | Add runtime checks, because we only currently check the defaults. Fixes: 278946301 Test: binderRpcTest Change-Id: I119c8c49d5938a9d6f36c29c1bb70732155c6037
* libbinder: RpcServer protocol version errorSteven Moreland2023-05-121-0/+12
| | | | | | | | | | | | Return an error if you set an invalid protocol version on an RpcServer. Previously, this would cause errors later down the line. Bug: 278946301 Test: binderRpcTest Change-Id: Id496f1d39b2a32ce775e585f7690ae59503dc3aa
* freeze rpc binder wire protocolSteven Moreland2023-04-241-1/+1
| | | | | | | | | for Android U Bug: 266741352 Test: binderRpcWireProtocolTest Change-Id: Iafa1f49a9f0f536162c59ff44143f05b61e9c9e8 Merged-In: Iafa1f49a9f0f536162c59ff44143f05b61e9c9e8
* Reland "RPC Binder: dropping all binders drops session"Steven Moreland2023-03-151-7/+31
| | | | | | | | | | | This reverts commit 30a96fcc9ef87244469c93c0dea087008dad58fd. Bug: 271830568 Fixes: 273486801 - also disabled clang-tidy check this is hitting Test: binderRpcTest Change-Id: I655cf2c2542b71aaab610cd9cbc5a7d53755178f
* Merge "Revert "Revert "libbinder: Flush excess refs after single async ↵Treehugger Robot2023-03-071-2/+2
|\ | | | | | | transaction"""
| * Revert "Revert "libbinder: Flush excess refs after single async transaction""Andrei Homescu2023-03-011-2/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 655d5710fdb42524376649df0ef9953437479cd6. Reason for revert: fixed OnewayCallQueuingWithFds Bug: 259517277 Test: binderRpcTestNoKernel --gtest_filter="*OnewayCallQueueingWithFds*" --gtest_repeat=10 --gtest_break_on_failure Change-Id: I7c6440232dbed2b1b808de64ddb23a4292c96428
* | libbinder: update RpcState transact commentsSteven Moreland2023-02-251-6/+6
|/ | | | | | | | | | A few of these have become out of date because - the exponential backoff lambda was moved - server shutdown was added on rpcSend failure Bug: N/A Test: N/A Change-Id: I12b5bef169cf2f2e04ad2f9cd709716d307b7b64
* Revert "libbinder: Flush excess refs after single async transaction"Steven Moreland2023-02-141-2/+2
| | | | | | | | | | | | This reverts commit 6aae53692e0a81ae263e25927214e79808cfdb38. Reason for revert: b/268238590 Bug: 268238590 Test: binderRpcTestNoKernel --gtest_filter="*OnewayCallQueueingWithFds/unix_domain_socket_bootstrap_raw_clientV4026531840_serverV4026531840_no_kernel*" --gtest_repeat=10000 --gtest_break_on_failure (this change causes tests to flake, reverting for now) Change-Id: I2dd4e347228791085f3f2534f948839ee27c16b6
* libbinder: Flush excess refs after single async transactionAndrei Homescu2023-01-261-2/+2
| | | | | | | | | | | After processing a single async transaction, RpcState previously returned without flushing the excess Binder references. This fixes the control flow so that the refs get flushed for any number of transactions. Bug: 259517277 Test: trusty_stats_test Change-Id: I2665f3b0d6120d4d79f46ef5141c9ff5f85fd5b5
* Merge "libbinder: add ancillaryFd support in RpcTransportTipcTrusty"Treehugger Robot2022-10-071-0/+15
|\
| * libbinder: add ancillaryFd support in RpcTransportTipcTrustyAndrei Homescu2022-10-051-0/+15
| | | | | | | | | | | | | | | | | | Implement ParcelFileDescriptor support in Trusty by adding support for ancillaryFd to RpcTransportTipcTrusty. Bug: 242940548 Test: Trusty tests Change-Id: Ic5602bbf9f239f65489e0f411f89b10907741be3
* | Merge "libbinder: Fix FD handling for queued oneway RPC transactions"Treehugger Robot2022-10-051-0/+2
|\ \ | |/ |/|
| * libbinder: Fix FD handling for queued oneway RPC transactionsFrederick Mayle2022-10-051-0/+2
| | | | | | | | | | | | | | | | | | | | If a oneway transaction contained FDs and got queued, we'd drop the FDs and then the Parcel validation would fail with an error once the transaction was eventually processed. Bug: 244484370 Test: m libbinder binderRpcTest && out/host/linux-x86/nativetest64/binderRpcTest/binderRpcTest Change-Id: I781d851d875d496c8b57e3512f3f89c9911e9f3c
* | libbinder: fix flake-mode buildSteven Moreland2022-09-281-1/+1
|/ | | | | | | | | Compile option to introduce random sleeps in the code to make certain rare flakes easier to reproduce. Bug: 244325464 Test: binderRpcTest w/ flake mode on Change-Id: Ibb78987f6550e0d6ec39b527059bfc517ea04492
* Merge "Add linkToDeath support for RPC binder so a client can act on disconnect"Devin Moore2022-07-211-0/+24
|\
| * Add linkToDeath support for RPC binder so a client can act on disconnectDevin Moore2022-07-201-0/+24
| | | | | | | | | | | | | | | | | | | | This requires an incoming thread to be listening to the connection in order to be notified. Test: atest binderRpcTest Test: atest binderRpcTestSingleThreaded Bug: 182939380 Change-Id: I3746de6e8cff99bb267867c5dc60a6815b19fb92
* | libbinder: RPC clear behaviorSteven Moreland2022-07-191-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when RpcState cleared its state in response to an error, there were two issues that might happen related to proxy destruction: - a BpBinder could have lost its last strong ref on another thread but not have the destruction reflected in RpcSession yet. This is the issue causing crashes in the callback test (when the call is oneway, callback is not oneway, and the call is delayed) - this code could run the BpBinder destructor if mNodeForBinder is the last wp<> holder of BpBinder (which has object lifetime weak). This could cause an issue hypothetically if an attached object (via attachObject) made binder calls in its destructor. In order to prevent this, 'binder' is held onto, instead of 'node.sentRef'. Fixes: 237330627 Test: (running for several minutes) m binderRpcTest && adb sync && adb shell "while /data/nativetest64/binderRpcTest/binderRpcTest --gtest_filter="*Callbacks*"; do logcat -c; done Change-Id: I21a702217b0749932d77c3acf11e879ee77dd22b
* | libbinder: Remove Parcel argument from Parcel::release_funcFrederick Mayle2022-07-151-6/+4
| | | | | | | | | | | | | | | | | | | | This enforces a clearer separation of concerns between the data owner and the parcel code. It happened to reveal an edge case where FDs are prematurely closed (tracking a fix in b/239222407). Test: TH Bug: 239222407 Change-Id: I54ff0c8e4a8f64afd529092d2038dac40c853371
* | Merge "libbinder: Don't abort when rpc parcel size is invalid"Frederick Mayle2022-07-151-6/+20
|\ \ | |/ |/|
| * libbinder: Don't abort when rpc parcel size is invalidFrederick Mayle2022-07-151-6/+20
| | | | | | | | | | | | | | | | | | No test becaue this is only reachable by bypassing the binder client library (i.e. writing non-sense directly to the socket). Test: binder_rpc_fuzzer Bug: 238497894 Change-Id: I85ef57df4b8970c35904a5e84e61cb87653a39be
* | libbinder: RPC node toStringSteven Moreland2022-07-151-17/+22
|/ | | | | | | | For better loggings. Bug: 237330627 Test: binderRpcTest Change-Id: I65b1f6ed087a5bd6e4de4341f554949e779c8c58
* libbinder: alternative in calling guard errorSteven Moreland2022-07-061-1/+2
| | | | | | Bug: 237245600 Test: binderRpcTest Change-Id: I89ad4e2e50ffd66105f9e31c4a274f9bb8abf34b
* libbinder: build option to disable the kernel IPC, part 1/2Steven Moreland2022-07-011-2/+4
| | | | | | | | | | Add a new BINDER_WITH_KERNEL_IPC macro to enable all code that uses IPCThreadState or ProcessState. This macro is defined for Android libbinder but left out for non-Android builds. Bug: 224644083 Test: m Change-Id: I622757fcc0f9885dbf271c0ffa84c54938d50774
* libbinder: add build option for single-threaded RPCAndrei Homescu2022-07-011-12/+12
| | | | | | | | | | Trusty does not support threading. This adds a build option to disable mutexes and other threading code from RpcState, RpcSession, and RpcServer. Bug: 224644083 Test: build Trusty Change-Id: Iaa78caca1ddee45be7c2def2755598decc0d4d15
* libbinder: Stricter protocol and code for receiving FDsFrederick Mayle2022-06-301-42/+54
| | | | | | | | | | | | | | | | | This is a slight change the to wire protocol. Now out-of-band FDs must be sent along with the command header bytes. The code changes exploit that by only using the more complex `recvmsg` call when reading the command header. Additionally, we explicitly pass around the list of FDs so that there is no risk of accumulating them. The same (somewhat ugly) vector type is used everywhere now so that there is only one allocation to capture the FDs and pass them to the `Parcel` object. Test: binderRpcTest Bug: 185909244 Change-Id: I1f55995ca82338ab9716fb2246c954ac8b16cfe5
* binder: Add FD support to RPC BinderFrederick Mayle2022-06-291-87/+190
| | | | | | Bug: 185909244 Test: TH Change-Id: Ic4fc1b1edfe9d69984e785553cd1aaca97a07da3
* libbinder: Add object offsets to RPC Binder protocolFrederick Mayle2022-06-171-13/+54
| | | | | | | | | | | | | | | | | | | | | The list of object offsets is always empty in this CL. That will change in follow up CLs when file descriptor support is added. The size of the parcel data is included in the RpcWireTransaction and RpcWireReply headers and then the object offsets are written after the parcel data. There was no space in RpcWireReply, so we must start a new wire protocol version. I've added some reserved space to RpcWireReply to match RpcWireTransaction so that it might be easier to make backwards compatible changes later. binderRpcTest on host went from 36 seconds to 2 minutes 24 seconds because of the added parameterization (x4 the tests => x4 the time). Bug: 185909244 Test: TH Change-Id: I0121a42f8b60362e6a6d0294a350255b5f9f5673
* libbinder: Don't alloc for RPC_COMMAND_DEC_STRONGFrederick Mayle2022-06-091-14/+10
| | | | | Test: TH Change-Id: I89eb9d87cd6d306d13b879649d209c6b6abd2494
* libbinder: Remove flexible array from RpcWireReplyFrederick Mayle2022-06-081-12/+17
| | | | | | | | | | | | | | | We are going to change the size of this struct depending on the protocol version and that gets messy when there is a flexible array member. We could remove it from RpcWireTransaction as well, but that is a bigger change and there is no motivation yet (besides consistency). This change also happens to optimize out one allocation when the reply parcel is zero bytes. Bug: 185909244 Test: TH Change-Id: I18a5712ba80e7b311b945ef54977b66ffa43e1ca
* Merge "Use android::base::function_ref isntead of std::function"Devin Moore2022-06-061-24/+25
|\
| * Use android::base::function_ref isntead of std::functionDevin Moore2022-06-061-24/+25
| | | | | | | | | | | | | | | | This removes an allocation from the binder RPC calls. Test: atest binderAllocationLimits Bug: 230625474 Change-Id: I70ebb4e320323149c3c66809f1077cbf332c07ef
* | binder: Use variant for backend specific Parcel fieldsFrederick Mayle2022-06-031-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This frees up some space to add RPC binder specific bookkeeping to Parcel. `variant` has a size overhead of one pointer, but since there is at least one pointer worth of fields in each case, it works out as an overall win. We could probably do it cheaper by using a union and hiding a bit field somewhere to indicate the active case, but that isn't necessary yet. Bug: 185909244 Test: TH Change-Id: Id53ea0cbfe51b3246e6f9f1f3d9df7c8c193808e
* | binder: Tweak overflow check for readabilityFrederick Mayle2022-05-311-10/+7
|/ | | | | Test: TH Change-Id: I01a9edd997095c03a35ceb4d75b3bb6df1863704
* libbinder: replace RpcTransport::peek() with pollRead()Andrei Homescu2022-05-171-4/+1
| | | | | | | | | | peek uses MSG_PEEK internally which only works with sockets. This refactors that function into a more specific pollRead() which works for e.g. pipes and other files. Bug: 224644083 Test: atest binderRpcTest Change-Id: I340fa7ee7a7bb2077115fc28835bcadf67db03d9
* libbinder: Print the iov number in RPC log messagesAndrei Homescu2022-03-301-2/+4
| | | | | | Bug: 224644083 Test: m Change-Id: Id6f981911491d543561b0306b25dd4ef44fa8e5e
* libbinder: Return status_t from RpcTransport::peek()Andrei Homescu2022-03-301-2/+8
| | | | | | | | | | Result<> pulls in over 100k of extra libc++ code on Trusty so this CL replaces it with status_t as the result type of RpcTransport::peek(). Bug: 224644083 Test: atest binderRpcTest Change-Id: Idde111245794dc4afd421f3a723feacc8c3a346e
* libbinder: Fix initializer order error in RpcState.cppAndrei Homescu2022-03-081-1/+1
| | | | | | | | | | | | Building with -Wreorder-init-list fails with an error in RpcState.cpp when initializing a BinderNode structure. This fixes the error by manually moving the initializers in the right order. Bug: None Test: m Change-Id: I81ca1f52ad0f6955f0a32658f8f367a3539baf06
* Fix building libbinder against muslColin Cross2022-01-271-8/+7
| | | | | | | | | | musl libc uses the posix definition of msg_iovlen as int. Change the niovs argument to an int, make sure it is not negative, and cast it to size_t if necessary. Bug: 190084016 Test: m USE_HOST_MUSL=true host-native Change-Id: I6ff9206e9e7396f2f89622735f790b4fac18f76c
* binder: Eliminate a data copy in RPC transport operationsAndrei Homescu2021-12-231-68/+47
| | | | | | | | | | Switch RpcTransportRaw to use sendmsg() and recvmsg() over iovecs to send data from multiple buffers to avoid having to copy all data into a single large buffer. Bug: 202878542 Test: atest binderRpcTest Change-Id: I8ba7fa815040555503160ae41888a0b0efe9e5d2
* libbinder: support server-specific sessionSteven Moreland2021-10-201-1/+3
| | | | | | | | | | | | | | When multiple clients connect to a server, we need a way to tell these clients apart. Having a per-client root object is the easiest way to do this (the alternative, using getCalling* like is used in binder, isn't so great because it requires global/thread local place, but given that many RpcSession objects can be created, and these can also be used in conjunction with kernel binder, it is complicated figuring out exactly where to call getCalling*). Bug: 199259751 Test: binderRpcTest Change-Id: I5727db618b5ea138bfa19e75ed915f6a6991518e