Merge "hwbinder: explicitly disallow local java binder"
am: c33c224b4e
Change-Id: I77af04cd56b8f5c4af4f320f3273ec610c3d087e
This commit is contained in:
@@ -224,6 +224,21 @@ status_t JHwBinder::onTransact(
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool validateCanUseHwBinder(const sp<hardware::IBinder>& binder) {
|
||||||
|
if (binder != nullptr && binder->localBinder() != nullptr) {
|
||||||
|
// untested/unsupported/inefficient
|
||||||
|
// see b/129150021, doesn't work with scatter-gather
|
||||||
|
//
|
||||||
|
// explicitly disabling until it is supported
|
||||||
|
// (note, even if this is fixed to work with scatter gather, we would also need
|
||||||
|
// to convert this to the Java object rather than re-wrapping with a proxy)
|
||||||
|
LOG(ERROR) << "Local Java Binder not supported.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -324,9 +339,9 @@ static jobject JHwBinder_native_getService(
|
|||||||
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, retry /* retry */, false /* getStub */);
|
sp<IBase> ret = getRawServiceInternal(ifaceName, serviceName, retry /* retry */, false /* getStub */);
|
||||||
sp<hardware::IBinder> service = hardware::toBinder<hidl::base::V1_0::IBase>(ret);
|
sp<hardware::IBinder> service = hardware::toBinder<hidl::base::V1_0::IBase>(ret);
|
||||||
|
|
||||||
if (service == NULL) {
|
if (service == nullptr || !validateCanUseHwBinder(service)) {
|
||||||
signalExceptionForError(env, NAME_NOT_FOUND);
|
signalExceptionForError(env, NAME_NOT_FOUND);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "HwBinder: Starting thread pool for getting: " << ifaceName << "/" << serviceName;
|
LOG(INFO) << "HwBinder: Starting thread pool for getting: " << ifaceName << "/" << serviceName;
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ private:
|
|||||||
|
|
||||||
int register_android_os_HwBinder(JNIEnv *env);
|
int register_android_os_HwBinder(JNIEnv *env);
|
||||||
|
|
||||||
|
bool validateCanUseHwBinder(const sp<hardware::IBinder>& binder);
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
#endif // _ANDROID_OS_HW_BINDER_H
|
#endif // _ANDROID_OS_HW_BINDER_H
|
||||||
|
|||||||
@@ -883,8 +883,12 @@ static jobject JHwParcel_native_readStrongBinder(JNIEnv *env, jobject thiz) {
|
|||||||
|
|
||||||
sp<hardware::IBinder> binder = parcel->readStrongBinder();
|
sp<hardware::IBinder> binder = parcel->readStrongBinder();
|
||||||
|
|
||||||
if (binder == NULL) {
|
if (binder == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validateCanUseHwBinder(binder)) {
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JHwRemoteBinder::NewObject(env, binder);
|
return JHwRemoteBinder::NewObject(env, binder);
|
||||||
|
|||||||
Reference in New Issue
Block a user