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

Commit 90debcab authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder: RPC drop extra header info" am: 6f9f5ea1 am: b024e3fb am: ec374220

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1653724

Change-Id: Iab92899bc0214e286332c3d8635fca81cf7bc5cb
parents 96496ba0 ec374220
Loading
Loading
Loading
Loading
+38 −32
Original line number Original line Diff line number Diff line
@@ -41,11 +41,12 @@
#include <binder/TextOutput.h>
#include <binder/TextOutput.h>


#include <cutils/ashmem.h>
#include <cutils/ashmem.h>
#include <cutils/compiler.h>
#include <utils/Flattenable.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/misc.h>
#include <utils/String8.h>
#include <utils/String16.h>
#include <utils/String16.h>
#include <utils/String8.h>
#include <utils/misc.h>


#include <private/binder/binder_module.h>
#include <private/binder/binder_module.h>
#include "RpcState.h"
#include "RpcState.h"
@@ -590,12 +591,14 @@ status_t Parcel::writeInterfaceToken(const String16& interface)
}
}


status_t Parcel::writeInterfaceToken(const char16_t* str, size_t len) {
status_t Parcel::writeInterfaceToken(const char16_t* str, size_t len) {
    if (CC_LIKELY(!isForRpc())) {
        const IPCThreadState* threadState = IPCThreadState::self();
        const IPCThreadState* threadState = IPCThreadState::self();
        writeInt32(threadState->getStrictModePolicy() | STRICT_MODE_PENALTY_GATHER);
        writeInt32(threadState->getStrictModePolicy() | STRICT_MODE_PENALTY_GATHER);
        updateWorkSourceRequestHeaderPosition();
        updateWorkSourceRequestHeaderPosition();
    writeInt32(threadState->shouldPropagateWorkSource() ?
        writeInt32(threadState->shouldPropagateWorkSource() ? threadState->getCallingWorkSourceUid()
            threadState->getCallingWorkSourceUid() : IPCThreadState::kUnsetWorkSource);
                                                            : IPCThreadState::kUnsetWorkSource);
        writeInt32(kHeader);
        writeInt32(kHeader);
    }


    // currently the interface identification token is just its name as a string
    // currently the interface identification token is just its name as a string
    return writeString16(str, len);
    return writeString16(str, len);
@@ -642,17 +645,17 @@ bool Parcel::enforceInterface(const char16_t* interface,
                              size_t len,
                              size_t len,
                              IPCThreadState* threadState) const
                              IPCThreadState* threadState) const
{
{
    if (CC_LIKELY(!isForRpc())) {
        // StrictModePolicy.
        // StrictModePolicy.
        int32_t strictPolicy = readInt32();
        int32_t strictPolicy = readInt32();
        if (threadState == nullptr) {
        if (threadState == nullptr) {
            threadState = IPCThreadState::self();
            threadState = IPCThreadState::self();
        }
        }
    if ((threadState->getLastTransactionBinderFlags() &
        if ((threadState->getLastTransactionBinderFlags() & IBinder::FLAG_ONEWAY) != 0) {
         IBinder::FLAG_ONEWAY) != 0) {
            // For one-way calls, the callee is running entirely
            // For one-way calls, the callee is running entirely
            // disconnected from the caller, so disable StrictMode entirely.
            // disconnected from the caller, so disable StrictMode entirely.
            // Not only does disk/network usage not impact the caller, but
            // Not only does disk/network usage not impact the caller, but
      // there's no way to commuicate back any violations anyway.
            // there's no way to communicate back violations anyway.
            threadState->setStrictModePolicy(0);
            threadState->setStrictModePolicy(0);
        } else {
        } else {
            threadState->setStrictModePolicy(strictPolicy);
            threadState->setStrictModePolicy(strictPolicy);
@@ -664,9 +667,12 @@ bool Parcel::enforceInterface(const char16_t* interface,
        // vendor header
        // vendor header
        int32_t header = readInt32();
        int32_t header = readInt32();
        if (header != kHeader) {
        if (header != kHeader) {
        ALOGE("Expecting header 0x%x but found 0x%x. Mixing copies of libbinder?", kHeader, header);
            ALOGE("Expecting header 0x%x but found 0x%x. Mixing copies of libbinder?", kHeader,
                  header);
            return false;
            return false;
        }
        }
    }

    // Interface descriptor.
    // Interface descriptor.
    size_t parcel_interface_len;
    size_t parcel_interface_len;
    const char16_t* parcel_interface = readString16Inplace(&parcel_interface_len);
    const char16_t* parcel_interface = readString16Inplace(&parcel_interface_len);