summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTri Vo <trong@google.com>2019-03-25 10:56:55 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-03-25 10:56:55 -0700
commit949b0ab116fcad32542c47bc1f05b0162b8261de (patch)
treef4f018d7160aeed26de6c6647023269b99a68626
parent0852dae273c4043bbac39b25ad6a1fb1807659bc (diff)
parent1ab425f1358e7c302296cb0bf65c3aadd4cbbd56 (diff)
downloadashmemd-949b0ab116fcad32542c47bc1f05b0162b8261de.tar.gz
Check /dev/binder access before calling defaultServiceManager() am: 41b7c70821 am: 5e682c2851
am: 1ab425f135 Change-Id: I6648512fd0d5074b7299f3b9148a9905c4f8c912
-rw-r--r--ashmemd_client.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/ashmemd_client.cpp b/ashmemd_client.cpp
index 3380209..04227ba 100644
--- a/ashmemd_client.cpp
+++ b/ashmemd_client.cpp
@@ -28,6 +28,11 @@ namespace android {
namespace ashmemd {
sp<IAshmemDeviceService> getAshmemService() {
+ // Calls to defaultServiceManager() crash the process if it doesn't have appropriate
+ // binder permissions. Check these permissions proactively.
+ if (access("/dev/binder", R_OK | W_OK) != 0) {
+ return nullptr;
+ }
sp<IServiceManager> sm = android::defaultServiceManager();
sp<IBinder> binder = sm->checkService(String16("ashmem_device_service"));
return interface_cast<IAshmemDeviceService>(binder);