From c709dd898617f795e5cccff9aa482423a162f0dd Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 5 Aug 2019 20:30:14 -0700 Subject: libbinder: stability check moved to trans time Before: stability check done when binder is read from a parcel After: stability check done when binder is transacted on Why this change is being made/benefits: - vendor binders can be used as tokens in system context - pingBinder/interfaceChain/etc.. can be done on vendor binders in a system context, so code can generically operate on binders. This is particularly useful for service manager and dumpstate, which previously I was going to special-case - policy on which binders go where is entirely reliant on SELinux whereas before there were additional runtime restrictions Cons to this change: - allowed binders must be determined by context. BpBinder now checks stability based on kLocalStability. More work would need to be done to get this working with APEX. Bug: 136027762 Test: binderStabilityTest Change-Id: Iff026e81a130dbb8885ca82ec24e69a5768847eb Merged-In: Iff026e81a130dbb8885ca82ec24e69a5768847eb --- libs/binder/Parcel.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'libs/binder/Parcel.cpp') diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index a2333ae07e..c75f0365f5 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -167,11 +168,10 @@ static void release_object(const sp& proc, status_t Parcel::finishFlattenBinder( const sp& /*binder*/, const flat_binder_object& flat) { - // internal::Stability::tryMarkCompilationUnit(binder.get()); - status_t status = writeObject(flat, false); if (status != OK) return status; + // internal::Stability::tryMarkCompilationUnit(binder.get()); // Cannot change wire protocol w/o SM update // return writeInt32(internal::Stability::get(binder.get())); return OK; @@ -185,10 +185,6 @@ status_t Parcel::finishUnflattenBinder( // status_t status = readInt32(&stability); // if (status != OK) return status; - // if (binder != nullptr && !internal::Stability::check(stability, mRequiredStability)) { - // return BAD_TYPE; - // } - // status = internal::Stability::set(binder.get(), stability, true /*log*/); // if (status != OK) return status; @@ -356,10 +352,6 @@ status_t Parcel::setDataCapacity(size_t size) return NO_ERROR; } -void Parcel::setTransactingBinder(const sp& binder) const { - mRequiredStability = internal::Stability::get(binder.get()); -} - status_t Parcel::setData(const uint8_t* buffer, size_t len) { if (len > INT32_MAX) { @@ -2615,10 +2607,9 @@ void Parcel::initState() mObjectsCapacity = 0; mNextObjectHint = 0; mObjectsSorted = false; - mAllowFds = true; mHasFds = false; mFdsKnown = true; - mRequiredStability = internal::Stability::UNDECLARED; + mAllowFds = true; mOwner = nullptr; mOpenAshmemSize = 0; -- cgit v1.2.3-59-g8ed1b