summaryrefslogtreecommitdiff
path: root/drm/1.0/default/CryptoPlugin.cpp
diff options
context:
space:
mode:
authorEdwin Wong <edwinwong@google.com>2021-01-26 20:29:25 -0800
committermosimchah <mosimchah@gmail.com>2021-04-13 02:27:59 -0400
commit7a2dddcebe36c2afea5fc5e98bcf3e18664d8517 (patch)
tree9b5668a2a7d87e28c958a920911c7ad17feeb28e /drm/1.0/default/CryptoPlugin.cpp
parentecaf9ced63a0f939545e2bcbe2a4636e98357521 (diff)
Fix potential decrypt src pointer overflow.q10.0
There is a potential integer overflow to bypass the source base size check in decrypt. The source pointer can then point to the outside of the source buffer, which could potentially leak arbitrary memory content to destination pointer. Test: sts-tradefed sts-tradefed run sts-engbuild-no-spl-lock -m StsHostTestCases --test android.security.sts.Bug_176496160#testPocBug_176496160 Test: push to device with target_hwasan-userdebug build adb shell /data/local/tmp/Bug-17649616064 Bug: 176496160 Bug: 176444786 Change-Id: I811a6f60948bde2a72906c2c6172fd7bc5feb6d9 (cherry picked from commit c14f262876818498b3ca77f1d6df9d4fb7e77b1c)
Diffstat (limited to 'drm/1.0/default/CryptoPlugin.cpp')
-rw-r--r--drm/1.0/default/CryptoPlugin.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp
index 2db360765..e6d4e8447 100644
--- a/drm/1.0/default/CryptoPlugin.cpp
+++ b/drm/1.0/default/CryptoPlugin.cpp
@@ -124,7 +124,11 @@ namespace implementation {
return Void();
}
- if (source.offset + offset + source.size > sourceBase->getSize()) {
+ size_t totalSize = 0;
+ if (__builtin_add_overflow(source.offset, offset, &totalSize) ||
+ __builtin_add_overflow(totalSize, source.size, &totalSize) ||
+ totalSize > sourceBase->getSize()) {
+ android_errorWriteLog(0x534e4554, "176496160");
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
return Void();
}