diff options
author | Tri Vo <trong@google.com> | 2019-03-25 10:48:48 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-25 10:48:48 -0700 |
commit | 1ab425f1358e7c302296cb0bf65c3aadd4cbbd56 (patch) | |
tree | f4f018d7160aeed26de6c6647023269b99a68626 | |
parent | 5b8024f3a484203650c3065e68391a6b26a265ab (diff) | |
parent | 5e682c2851eb5951d08083b5ee7acde2537f473d (diff) | |
download | ashmemd-1ab425f1358e7c302296cb0bf65c3aadd4cbbd56.tar.gz |
Check /dev/binder access before calling defaultServiceManager() am: 41b7c70821
am: 5e682c2851
Change-Id: Iaa776c7824bd4986d5618d2d5f2208ca023a5e99
-rw-r--r-- | ashmemd_client.cpp | 5 |
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); |