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

Commit 4a03d784 authored by Wei Jia's avatar Wei Jia
Browse files

DO NOT MERGE - OMX: allow only secure codec to remotely call allocateBuffer.

Bug: 24310423
Change-Id: Iebcfc58b447f925ec2134898060af2ef227266a3
(cherry picked from commit 8dde7269)
parent 74d1927e
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -203,6 +203,12 @@ public:
    virtual status_t onTransact(
    virtual status_t onTransact(
            uint32_t code, const Parcel &data, Parcel *reply,
            uint32_t code, const Parcel &data, Parcel *reply,
            uint32_t flags = 0);
            uint32_t flags = 0);

protected:
    // check if the codec is secure.
    virtual bool isSecure(IOMX::node_id node) {
        return false;
    }
};
};


class BnOMXObserver : public BnInterface<IOMXObserver> {
class BnOMXObserver : public BnInterface<IOMXObserver> {
+6 −0
Original line number Original line Diff line number Diff line
@@ -810,6 +810,12 @@ status_t BnOMX::onTransact(


            node_id node = (void*)data.readIntPtr();
            node_id node = (void*)data.readIntPtr();
            OMX_U32 port_index = data.readInt32();
            OMX_U32 port_index = data.readInt32();
            if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) {
                ALOGE("b/24310423");
                reply->writeInt32(INVALID_OPERATION);
                return NO_ERROR;
            }

            size_t size = data.readInt32();
            size_t size = data.readInt32();


            buffer_id buffer;
            buffer_id buffer;
+2 −0
Original line number Original line Diff line number Diff line
@@ -126,6 +126,8 @@ public:


    virtual void binderDied(const wp<IBinder> &the_late_who);
    virtual void binderDied(const wp<IBinder> &the_late_who);


    virtual bool isSecure(IOMX::node_id node);

    OMX_ERRORTYPE OnEvent(
    OMX_ERRORTYPE OnEvent(
            node_id node,
            node_id node,
            OMX_IN OMX_EVENTTYPE eEvent,
            OMX_IN OMX_EVENTTYPE eEvent,
+6 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@ struct GraphicBufferSource;


struct OMXNodeInstance {
struct OMXNodeInstance {
    OMXNodeInstance(
    OMXNodeInstance(
            OMX *owner, const sp<IOMXObserver> &observer);
            OMX *owner, const sp<IOMXObserver> &observer, const char *name);


    void setHandle(OMX::node_id node_id, OMX_HANDLETYPE handle);
    void setHandle(OMX::node_id node_id, OMX_HANDLETYPE handle);


@@ -110,6 +110,10 @@ struct OMXNodeInstance {
            const void *data,
            const void *data,
            size_t size);
            size_t size);


    bool isSecure() const {
        return mIsSecure;
    }

    void onMessage(const omx_message &msg);
    void onMessage(const omx_message &msg);
    void onObserverDied(OMXMaster *master);
    void onObserverDied(OMXMaster *master);
    void onGetHandleFailed();
    void onGetHandleFailed();
@@ -125,6 +129,7 @@ private:
    OMX_HANDLETYPE mHandle;
    OMX_HANDLETYPE mHandle;
    sp<IOMXObserver> mObserver;
    sp<IOMXObserver> mObserver;
    bool mDying;
    bool mDying;
    bool mIsSecure;


    // Lock only covers mGraphicBufferSource.  We can't always use mLock
    // Lock only covers mGraphicBufferSource.  We can't always use mLock
    // because of rare instances where we'd end up locking it recursively.
    // because of rare instances where we'd end up locking it recursively.
+6 −1
Original line number Original line Diff line number Diff line
@@ -185,6 +185,11 @@ void OMX::binderDied(const wp<IBinder> &the_late_who) {
    instance->onObserverDied(mMaster);
    instance->onObserverDied(mMaster);
}
}


bool OMX::isSecure(node_id node) {
    OMXNodeInstance *instance = findInstance(node);
    return (instance == NULL ? false : instance->isSecure());
}

bool OMX::livesLocally(node_id node, pid_t pid) {
bool OMX::livesLocally(node_id node, pid_t pid) {
    return pid == getpid();
    return pid == getpid();
}
}
@@ -223,7 +228,7 @@ status_t OMX::allocateNode(


    *node = 0;
    *node = 0;


    OMXNodeInstance *instance = new OMXNodeInstance(this, observer);
    OMXNodeInstance *instance = new OMXNodeInstance(this, observer, name);


    OMX_COMPONENTTYPE *handle;
    OMX_COMPONENTTYPE *handle;
    OMX_ERRORTYPE err = mMaster->makeComponentInstance(
    OMX_ERRORTYPE err = mMaster->makeComponentInstance(
Loading