summaryrefslogtreecommitdiff
path: root/libs/binder/Debug.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2020-11-11 02:14:45 +0000
committer Steven Moreland <smoreland@google.com> 2021-03-24 01:53:36 +0000
commit5553ac45e0cb23102016858789603d6e12ab456b (patch)
tree91ac048b06ce5af9ea26c296e48471cb3f3fe2b7 /libs/binder/Debug.cpp
parenta647f2bc257e4eb59923e097c4e225643ecf38cf (diff)
libbinder: support calls over sockets
Minimal-ish change for basic binder RPC. This enables binder to work over sockets. The main change to core code is in 'Parcel' and 'BpBinder'. The Parcel format is now associated with the binder that it is either for or a reply from (we no longer have binder 'objects' for the kernel). BpBinder is extended to support talking over sockets (ideally, this would be a subclass, but IBinder::localBinder/remoteBinder mean there is a lot of code which presupposes what type of binder we have). In addition, we have a few new objects: - RpcServer - set this up to serve a connection - RpcConnection - symmetrical object handling dispatch to a known server/client - RpcAddress - (this will definitely change) randomly generated addresses - this might include things like host VM context, ip address, or similar in the future. In that case, the address generation should be cryptographically secure. - RpcState - this keeps track of known binders, their refcounts, and async transactions, and it understand the binder socket wire protocol The connection itself looks like N socket accepts to a server (the server might have M socket accepts back to the client for symmetrical connections, that is connections which need more than nested transactions). The number of these socket connections controls how many synchronous transactions can be made. Wherever possible, the behavior here seeks to mimick the binder driver, and some differences are documented in the code. After this CL merges, the future work I intend on completing includes: - support to work over vsock - performance benchmarking - optimization of the socket code here (may include delaying refcounts) - support to pass 'transitive' binders (pass a binder from one service to a different service, to let it setup a new connection). This task may be excluded from my efforts as a security hedge if I can manage. - fuzzer for this wire format - support for linkToDeath - support for transaction encryption - support for promoting from a weak pointer - handling SIGPIPE for dead connections - and many more! :) Bug: 167966510 Test: binderRpcTest Change-Id: I276c6e312f584b57f4e7a14389ea4a1d63cfa2f4
Diffstat (limited to 'libs/binder/Debug.cpp')
-rw-r--r--libs/binder/Debug.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp
index e4ac4b49a4..86769551d7 100644
--- a/libs/binder/Debug.cpp
+++ b/libs/binder/Debug.cpp
@@ -26,6 +26,22 @@
namespace android {
+std::string hexString(const void* bytes, size_t len) {
+ if (bytes == nullptr) return "<null>";
+
+ const uint8_t* bytes8 = static_cast<const uint8_t*>(bytes);
+ const char chars[] = "0123456789abcdef";
+ std::string result;
+ result.resize(len * 2);
+
+ for (size_t i = 0; i < len; i++) {
+ result[2 * i] = chars[bytes8[i] >> 4];
+ result[2 * i + 1] = chars[bytes8[i] & 0xf];
+ }
+
+ return result;
+}
+
// ---------------------------------------------------------------------
static const char indentStr[] =