Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a44d2447 authored by Edwin Wong's avatar Edwin Wong
Browse files

[RESTRICT AUTOMERGE] 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: I38e25c63c67b8acfa69649cc906483430da2ead6
parent eb95e3ce
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -111,8 +111,10 @@ Return<void> CryptoPlugin::decrypt(
    }

    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::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
        return Void();
    }