summaryrefslogtreecommitdiff
path: root/libs/binder/RpcState.cpp
AgeCommit message (Collapse)Author
2025-09-18[SP 2025-09-01] RPC Binder: clearer errors for wrong transact type Steven Moreland
Bug: 423127919 # this bug error is totally different than this case. If we hit this case, we would have gotten a different harder error. However, I found this while looking at this bug. Bug: 416734088 Test: binderRpcTest Flag: EXEMPT bug fix Change-Id: I3e0db452ebeed1a520ffc0181ed3577eb38bea9a Merged-In: I3e0db452ebeed1a520ffc0181ed3577eb38bea9a (cherry picked from commit 51ed14eebf5a6b7e0d1d6f5b9c81b01a666b270a)
2025-09-18[SP 2025-09-01] RPC Binder: shutdown on SPAN error. Steven Moreland
This error return is not recoverable. Bug: 416734088 Test: binderRpcTest Change-Id: If0b8a8f36f797dcf927bfc2b5ae51e37e915f2f6 Merged-In: If0b8a8f36f797dcf927bfc2b5ae51e37e915f2f6 (cherry picked from commit dddbc115f88d99379ad9e118e551924c84f16e3a)
2025-09-18[SP 2025-09-01] RPC Binder: shutdown on ENOMEM Steven Moreland
We were expecting crashes in these case, but explicitly shut down. More work needs to be done to ignore transactions in out of memory conditions. Bug: 404210068 Bug: 414720799 Bug: 416734088 Test: binderRpcTest Change-Id: Iaf9a34b4031fb7b9807c962bcc67de8cd9102088 Merged-In: Iaf9a34b4031fb7b9807c962bcc67de8cd9102088 (cherry picked from commit cba4e3642a8a58d54481ed4c14f179bcc7f9ae70)
2025-01-28RPC Binder: increase transaction size Steven Moreland
One of the RPC Binder usecases requires a larger transaction limit. This change increases the limit, and it unifies the 'too large transaction' logging from regular and RPC binder. This hopefully makes it more clear why there is a limit there, we want to keep code compatible between the two transports. A test is added to show the current behavior. When a transaction which is sent is too large, the server closes the session. This is probably the correct behavior for too large replies, but for too large transactions, the client could handle these errors. b/392717039 is filed to investigate inconsistencies raised in the test more deeply. Fixes: 392575419 Test: atest binderRpcTest --test-filter="*LargeVector*" Change-Id: I2eeb08818c10371c7f77a35abee7d4e46bb63d72
2023-11-17Binder unique_fd Tomasz Wasilczyk
Test: mma Bug: 302723053 Change-Id: I52f14cadb027b3f854946d5315dce3d23aa21b19
2023-11-04Revert^2 "Use std::function instead of base::function_ref" Tomasz Wasilczyk
84b7cff1a7082d32e9043014e57db7b4ed2aa7a0 Test: m Bug: 302723053 Change-Id: If25bdb65254a4a8ad5afeda7e6ce1eedf422d896
2023-11-04Revert^2 "Use std::unique_ptr instead of ScopeGuard" Tomasz Wasilczyk
25c1a3b8543dd1756308424dd65030f90bb7a99f Test: m Bug: 302723053 Change-Id: Id9355c10d78d0c55afb49f512b78bb0923fbc4f7
2023-11-03Binder: migrate off libbase macros Tomasz Wasilczyk
Test: mma Bug: 302723053 Change-Id: Ie7c13c324311f600d72bc8ecc4157ad6c46259a0
2023-10-30RPC Binder: limit experimental wire protocol use Steven Moreland
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
2023-10-25Migrate off of base::StringPrintf Tomasz Wasilczyk
Bug: 302723053 Test: mma Change-Id: Id7f0b1d0a11747a5a61a2550f05d7caaabf339a3
2023-10-17Merge "binderRpcTest: conditional experimental protocol" into main Steven Moreland
2023-10-17binderRpcTest: conditional experimental protocol Steven Moreland
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
2023-10-12Copy HexString to libbinder Tomasz Wasilczyk
Bug: 302723053 Test: mma Change-Id: I5c7a71a91b7dc95bfa0cd653eabe554bdd3f7812
2023-06-28Make sure to handle new RpcSession::FileDescriptorTransportMode Tomasz Wasilczyk
Bug: 289151149 Test: binder_rpc_test Change-Id: I0944e94e52219c6f040c304f50e70a16f5ae25cd
2023-05-31RPC binder: limit experimental wire protocol usage Steven Moreland
Add runtime checks, because we only currently check the defaults. Fixes: 278946301 Test: binderRpcTest Change-Id: I119c8c49d5938a9d6f36c29c1bb70732155c6037
2023-05-12libbinder: RpcServer protocol version error Steven Moreland
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
2023-04-24freeze rpc binder wire protocol Steven Moreland
for Android U Bug: 266741352 Test: binderRpcWireProtocolTest Change-Id: Iafa1f49a9f0f536162c59ff44143f05b61e9c9e8 Merged-In: Iafa1f49a9f0f536162c59ff44143f05b61e9c9e8
2023-03-15Reland "RPC Binder: dropping all binders drops session" Steven Moreland
This reverts commit 30a96fcc9ef87244469c93c0dea087008dad58fd. Bug: 271830568 Fixes: 273486801 - also disabled clang-tidy check this is hitting Test: binderRpcTest Change-Id: I655cf2c2542b71aaab610cd9cbc5a7d53755178f
2023-03-07Merge "Revert "Revert "libbinder: Flush excess refs after single async ↵ Treehugger Robot
transaction"""
2023-03-01Revert "Revert "libbinder: Flush excess refs after single async transaction"" Andrei Homescu
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
2023-02-25libbinder: update RpcState transact comments Steven Moreland
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
2023-02-14Revert "libbinder: Flush excess refs after single async transaction" Steven Moreland
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
2023-01-26libbinder: Flush excess refs after single async transaction Andrei Homescu
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
2022-10-07Merge "libbinder: add ancillaryFd support in RpcTransportTipcTrusty" Treehugger Robot
2022-10-05Merge "libbinder: Fix FD handling for queued oneway RPC transactions" Treehugger Robot
2022-10-05libbinder: add ancillaryFd support in RpcTransportTipcTrusty Andrei Homescu
Implement ParcelFileDescriptor support in Trusty by adding support for ancillaryFd to RpcTransportTipcTrusty. Bug: 242940548 Test: Trusty tests Change-Id: Ic5602bbf9f239f65489e0f411f89b10907741be3
2022-10-05libbinder: Fix FD handling for queued oneway RPC transactions Frederick Mayle
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
2022-09-28libbinder: fix flake-mode build Steven Moreland
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
2022-07-21Merge "Add linkToDeath support for RPC binder so a client can act on disconnect" Devin Moore
2022-07-20Add linkToDeath support for RPC binder so a client can act on disconnect Devin Moore
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
2022-07-19libbinder: RPC clear behavior Steven Moreland
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
2022-07-15libbinder: Remove Parcel argument from Parcel::release_func Frederick Mayle
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
2022-07-15Merge "libbinder: Don't abort when rpc parcel size is invalid" Frederick Mayle
2022-07-15libbinder: Don't abort when rpc parcel size is invalid Frederick Mayle
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
2022-07-15libbinder: RPC node toString Steven Moreland
For better loggings. Bug: 237330627 Test: binderRpcTest Change-Id: I65b1f6ed087a5bd6e4de4341f554949e779c8c58
2022-07-06libbinder: alternative in calling guard error Steven Moreland
Bug: 237245600 Test: binderRpcTest Change-Id: I89ad4e2e50ffd66105f9e31c4a274f9bb8abf34b
2022-07-01libbinder: build option to disable the kernel IPC, part 1/2 Steven Moreland
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
2022-07-01libbinder: add build option for single-threaded RPC Andrei Homescu
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
2022-06-30libbinder: Stricter protocol and code for receiving FDs Frederick Mayle
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
2022-06-29binder: Add FD support to RPC Binder Frederick Mayle
Bug: 185909244 Test: TH Change-Id: Ic4fc1b1edfe9d69984e785553cd1aaca97a07da3
2022-06-17libbinder: Add object offsets to RPC Binder protocol Frederick Mayle
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
2022-06-09libbinder: Don't alloc for RPC_COMMAND_DEC_STRONG Frederick Mayle
Test: TH Change-Id: I89eb9d87cd6d306d13b879649d209c6b6abd2494
2022-06-08libbinder: Remove flexible array from RpcWireReply Frederick Mayle
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
2022-06-06Merge "Use android::base::function_ref isntead of std::function" Devin Moore
2022-06-06Use android::base::function_ref isntead of std::function Devin Moore
This removes an allocation from the binder RPC calls. Test: atest binderAllocationLimits Bug: 230625474 Change-Id: I70ebb4e320323149c3c66809f1077cbf332c07ef
2022-06-03binder: Use variant for backend specific Parcel fields Frederick Mayle
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
2022-05-31binder: Tweak overflow check for readability Frederick Mayle
Test: TH Change-Id: I01a9edd997095c03a35ceb4d75b3bb6df1863704
2022-05-17libbinder: replace RpcTransport::peek() with pollRead() Andrei Homescu
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
2022-03-30libbinder: Print the iov number in RPC log messages Andrei Homescu
Bug: 224644083 Test: m Change-Id: Id6f981911491d543561b0306b25dd4ef44fa8e5e
2022-03-30libbinder: Return status_t from RpcTransport::peek() Andrei Homescu
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