summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Wong <edwinwong@google.com>2021-02-02 21:36:34 -0800
committerEdwin Wong <edwinwong@google.com>2021-02-25 17:53:57 +0000
commit49c0fe413ceb2e0cef356d2738d63bb873845e04 (patch)
tree9a3f013fcb9373b65ace30e33ab32a5afd15ec76
parent23a3c612893597b2c1d6507ef9c94ae25f8cdcbe (diff)
Fix potential decrypt destPtr overflow.
There is a potential integer overflow to bypass the destination base size check in decrypt. The destPtr can then point to the outside of the destination buffer. Test: sts-tradefed sts-tradefed run sts-engbuild-no-spl-lock -m StsHostTestCases --test android.security.sts.Bug_176444622#testPocBug_176444622 Test: push to device with target_hwasan-userdebug build adb shell /data/local/tmp/Bug-17644462264 Bug: 176444622 Bug: 176496353 Change-Id: Idac48307edd45fc8282902c4beeb2c8ca94f8cf3 Merged-In: Idac48307edd45fc8282902c4beeb2c8ca94f8cf3
-rw-r--r--drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
index d278633482..005e551383 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
@@ -142,12 +142,14 @@ Return<void> CryptoPlugin::decrypt_1_2(
base = static_cast<uint8_t *>(static_cast<void *>(destBase->getPointer()));
- if (destBuffer.offset + destBuffer.size > destBase->getSize()) {
+ totalSize = 0;
+ if (__builtin_add_overflow(destBuffer.offset, destBuffer.size, &totalSize) ||
+ totalSize > destBase->getSize()) {
+ android_errorWriteLog(0x534e4554, "176444622");
_hidl_cb(Status_V1_2::ERROR_DRM_FRAME_TOO_LARGE, 0, "invalid buffer size");
return Void();
}
- destPtr = static_cast<void *>(base + destination.nonsecureMemory.offset);
-
+ destPtr = static_cast<void*>(base + destination.nonsecureMemory.offset);
// Calculate the output buffer size and determine if any subsamples are
// encrypted.