From a81c63b08ca32ff4aab89fe958b9afb1c3c16a92 Mon Sep 17 00:00:00 2001 From: Gil Cukierman Date: Mon, 17 Mar 2025 15:56:57 -0400 Subject: libbinder: fix trusty cpp fd transport modes This moves the call to set allowed file descriptor transport modes to a common method that is invoked on both cpp and rust construction of RpcServerTrusty objects. Test: atest -c frameworks/native/libs/binder/tests/ Bug: 393346719 Change-Id: I0ec04676ff36879ce2b40f5070214b1cbe21f2b0 --- libs/binder/trusty/include/binder/RpcServerTrusty.h | 9 +++++++++ .../rust/binder_rpc_server_bindgen/cpp/ARpcServerTrusty.cpp | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'libs') diff --git a/libs/binder/trusty/include/binder/RpcServerTrusty.h b/libs/binder/trusty/include/binder/RpcServerTrusty.h index 127676bf9a..1ac00ca13f 100644 --- a/libs/binder/trusty/include/binder/RpcServerTrusty.h +++ b/libs/binder/trusty/include/binder/RpcServerTrusty.h @@ -97,6 +97,15 @@ private: // By default we use the latest stable version. LOG_ALWAYS_FATAL_IF(!rpcServer->setProtocolVersion(RPC_WIRE_PROTOCOL_VERSION)); + // The default behavior in trusty is to allow handles to be passed with tipc IPC. + // We add mode NONE so that servers do not reject connections from clients who do + // not change their default transport mode. + static const std::vector + TRUSTY_SERVER_SUPPORTED_FD_MODES = {RpcSession::FileDescriptorTransportMode::TRUSTY, + RpcSession::FileDescriptorTransportMode::NONE}; + + rpcServer->setSupportedFileDescriptorTransportModes(TRUSTY_SERVER_SUPPORTED_FD_MODES); + return rpcServer; } diff --git a/libs/binder/trusty/rust/binder_rpc_server_bindgen/cpp/ARpcServerTrusty.cpp b/libs/binder/trusty/rust/binder_rpc_server_bindgen/cpp/ARpcServerTrusty.cpp index 12e347e4f3..451383a90a 100644 --- a/libs/binder/trusty/rust/binder_rpc_server_bindgen/cpp/ARpcServerTrusty.cpp +++ b/libs/binder/trusty/rust/binder_rpc_server_bindgen/cpp/ARpcServerTrusty.cpp @@ -27,13 +27,6 @@ using android::RpcTransportCtxFactoryTipcTrusty; using android::sp; using android::wp; -// The default behavior in trusty is to allow handles to be passed with tipc IPC. -// We add mode NONE so that servers do not reject connections from clients who do -// not change their default transport mode. -static const std::vector TRUSTY_SERVER_SUPPORTED_FD_MODES = - {RpcSession::FileDescriptorTransportMode::TRUSTY, - RpcSession::FileDescriptorTransportMode::NONE}; - struct ARpcServerTrusty { sp mRpcServer; @@ -60,8 +53,6 @@ ARpcServerTrusty* ARpcServerTrusty_newPerSession(AIBinder* (*cb)(const void*, si return nullptr; } - rpcServer->setSupportedFileDescriptorTransportModes(TRUSTY_SERVER_SUPPORTED_FD_MODES); - rpcServer->setPerSessionRootObject( [cb, cbArgSp](wp /*session*/, const void* addrPtr, size_t len) { auto* aib = (*cb)(addrPtr, len, cbArgSp.get()); -- cgit v1.2.3-59-g8ed1b