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

Commit 518b68fd authored by Ray Essick's avatar Ray Essick
Browse files

Fix CFI issues with extractor threading

Recent changes in libutils exposed some issues where a library was
linked both static and shared into the extractor. This caused CFI
crashes in the extractor during DRM MediaCas processing.

The plugin where this triggered has been modified to (1) use the shared
library instance and (2) change from Mutex to std::mutex to reduce
dependency on that code.

Bug: 379803959
Test: CtsMediaDrmFrameworkTestCases:android.media.drmframework.cts.MediaDrmClearkeyTest
Flag: EXEMPT bugfix
Change-Id: I5ea5337b2b8816f64f5a28b7b144d710fc2f8123
parent f81f69e5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ cc_library {

    shared_libs: [
        "libbase",
        "libutils",
    ],

    header_libs: [
@@ -70,7 +71,6 @@ cc_library {
        "libstagefright_foundation_without_imemory",
        "libstagefright_mpeg2extractor",
        "libstagefright_mpeg2support_nocrypto",
        "libutils",
    ],

    apex_available: [
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ uint32_t MPEG2PSExtractor::flags() const {
}

status_t MPEG2PSExtractor::feedMore() {
    Mutex::Autolock autoLock(mLock);
    std::lock_guard<std::mutex> autoLock(mLock);

    // How much data we're reading at a time
    static const size_t kChunkSize = 8192;
+1 −1
Original line number Diff line number Diff line
@@ -479,7 +479,7 @@ void MPEG2TSExtractor::init() {
}

status_t MPEG2TSExtractor::feedMore(bool isInit) {
    Mutex::Autolock autoLock(mLock);
    std::lock_guard<std::mutex> autoLock(mLock);

    uint8_t packet[kTSPacketSize];
    ssize_t n = mDataSource->readAt(mOffset + mHeaderSkip, packet, kTSPacketSize);
+3 −2
Original line number Diff line number Diff line
@@ -18,11 +18,12 @@

#define MPEG2_PS_EXTRACTOR_H_

#include <mutex>

#include <media/stagefright/foundation/ABase.h>
#include <media/MediaExtractorPluginApi.h>
#include <media/MediaExtractorPluginHelper.h>
#include <media/stagefright/MetaDataBase.h>
#include <utils/threads.h>
#include <utils/KeyedVector.h>

namespace android {
@@ -51,7 +52,7 @@ private:
    struct Track;
    struct WrappedTrack;

    mutable Mutex mLock;
    std::mutex mLock;
    DataSourceHelper *mDataSource;

    off64_t mOffset;
+3 −2
Original line number Diff line number Diff line
@@ -19,12 +19,13 @@

#define MPEG2_TS_EXTRACTOR_H_

#include <mutex>

#include <media/stagefright/foundation/ABase.h>
#include <media/MediaExtractorPluginApi.h>
#include <media/MediaExtractorPluginHelper.h>
#include <media/stagefright/MetaDataBase.h>
#include <mpeg2ts/ATSParser.h>
#include <utils/threads.h>
#include <utils/KeyedVector.h>
#include <utils/Vector.h>

@@ -57,7 +58,7 @@ protected:
private:
    friend struct MPEG2TSSource;

    mutable Mutex mLock;
    std::mutex mLock;

    DataSourceHelper *mDataSource;