summaryrefslogtreecommitdiff
path: root/libs/binder/RpcState.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2023-05-31 20:49:11 +0000
committer Steven Moreland <smoreland@google.com> 2023-05-31 23:12:03 +0000
commit09034a905676afd72d351994142fceece2ac48a2 (patch)
tree86cd54933f0abc58b10880011cf1b905de69c670 /libs/binder/RpcState.cpp
parent4afa2c395765c7d944505c94f46c4172f6476975 (diff)
RPC binder: limit experimental wire protocol usage
Add runtime checks, because we only currently check the defaults. Fixes: 278946301 Test: binderRpcTest Change-Id: I119c8c49d5938a9d6f36c29c1bb70732155c6037
Diffstat (limited to 'libs/binder/RpcState.cpp')
-rw-r--r--libs/binder/RpcState.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index ff35f5f35c..5c1b2305a6 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -34,6 +34,10 @@
#include <inttypes.h>
+#ifdef __ANDROID__
+#include <cutils/properties.h>
+#endif
+
namespace android {
using base::StringPrintf;
@@ -399,14 +403,27 @@ status_t RpcState::rpcRec(
}
bool RpcState::validateProtocolVersion(uint32_t version) {
- if (version >= RPC_WIRE_PROTOCOL_VERSION_NEXT &&
- version != RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) {
+ if (version == RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) {
+#if defined(__ANDROID__)
+ char codename[PROPERTY_VALUE_MAX];
+ property_get("ro.build.version.codename", codename, "");
+ if (!strcmp(codename, "REL")) {
+ ALOGE("Cannot use experimental RPC binder protocol on a release branch.");
+ return false;
+ }
+#else
+ // don't restrict on other platforms, though experimental should
+ // only really be used for testing, we don't have a good way to see
+ // what is shipping outside of Android
+#endif
+ } else if (version >= RPC_WIRE_PROTOCOL_VERSION_NEXT) {
ALOGE("Cannot use RPC binder protocol version %u which is unknown (current protocol "
"version "
"is %u).",
version, RPC_WIRE_PROTOCOL_VERSION);
return false;
}
+
return true;
}