am 63070856: Merge "Don\'t propagate StrictMode over one-way Binder calls." into gingerbread
Merge commit '63070856d034a2819a26560bc7f2881e501c78b7' into gingerbread-plus-aosp * commit '63070856d034a2819a26560bc7f2881e501c78b7': Don't propagate StrictMode over one-way Binder calls.
This commit is contained in:
@@ -270,6 +270,7 @@ protected:
|
|||||||
|
|
||||||
IPCThreadState* thread_state = IPCThreadState::self();
|
IPCThreadState* thread_state = IPCThreadState::self();
|
||||||
const int strict_policy_before = thread_state->getStrictModePolicy();
|
const int strict_policy_before = thread_state->getStrictModePolicy();
|
||||||
|
thread_state->setLastTransactionBinderFlags(flags);
|
||||||
|
|
||||||
//printf("Transact from %p to Java code sending: ", this);
|
//printf("Transact from %p to Java code sending: ", this);
|
||||||
//data.print();
|
//data.print();
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ public:
|
|||||||
|
|
||||||
void setStrictModePolicy(int32_t policy);
|
void setStrictModePolicy(int32_t policy);
|
||||||
int32_t getStrictModePolicy() const;
|
int32_t getStrictModePolicy() const;
|
||||||
|
|
||||||
|
void setLastTransactionBinderFlags(int32_t flags);
|
||||||
|
int32_t getLastTransactionBinderFlags() const;
|
||||||
|
|
||||||
int64_t clearCallingIdentity();
|
int64_t clearCallingIdentity();
|
||||||
void restoreCallingIdentity(int64_t token);
|
void restoreCallingIdentity(int64_t token);
|
||||||
|
|
||||||
@@ -113,6 +116,7 @@ private:
|
|||||||
pid_t mCallingPid;
|
pid_t mCallingPid;
|
||||||
uid_t mCallingUid;
|
uid_t mCallingUid;
|
||||||
int32_t mStrictModePolicy;
|
int32_t mStrictModePolicy;
|
||||||
|
int32_t mLastTransactionBinderFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|||||||
@@ -377,6 +377,16 @@ int32_t IPCThreadState::getStrictModePolicy() const
|
|||||||
return mStrictModePolicy;
|
return mStrictModePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IPCThreadState::setLastTransactionBinderFlags(int32_t flags)
|
||||||
|
{
|
||||||
|
mLastTransactionBinderFlags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t IPCThreadState::getLastTransactionBinderFlags() const
|
||||||
|
{
|
||||||
|
return mLastTransactionBinderFlags;
|
||||||
|
}
|
||||||
|
|
||||||
void IPCThreadState::restoreCallingIdentity(int64_t token)
|
void IPCThreadState::restoreCallingIdentity(int64_t token)
|
||||||
{
|
{
|
||||||
mCallingUid = (int)(token>>32);
|
mCallingUid = (int)(token>>32);
|
||||||
@@ -598,8 +608,10 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPCThreadState::IPCThreadState()
|
IPCThreadState::IPCThreadState()
|
||||||
: mProcess(ProcessState::self()), mMyThreadId(androidGetTid()),
|
: mProcess(ProcessState::self()),
|
||||||
mStrictModePolicy(0)
|
mMyThreadId(androidGetTid()),
|
||||||
|
mStrictModePolicy(0),
|
||||||
|
mLastTransactionBinderFlags(0)
|
||||||
{
|
{
|
||||||
pthread_setspecific(gTLS, this);
|
pthread_setspecific(gTLS, this);
|
||||||
clearCaller();
|
clearCaller();
|
||||||
@@ -983,11 +995,11 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
|
|||||||
}
|
}
|
||||||
if (tr.target.ptr) {
|
if (tr.target.ptr) {
|
||||||
sp<BBinder> b((BBinder*)tr.cookie);
|
sp<BBinder> b((BBinder*)tr.cookie);
|
||||||
const status_t error = b->transact(tr.code, buffer, &reply, 0);
|
const status_t error = b->transact(tr.code, buffer, &reply, tr.flags);
|
||||||
if (error < NO_ERROR) reply.setError(error);
|
if (error < NO_ERROR) reply.setError(error);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const status_t error = the_context_object->transact(tr.code, buffer, &reply, 0);
|
const status_t error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);
|
||||||
if (error < NO_ERROR) reply.setError(error);
|
if (error < NO_ERROR) reply.setError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -464,7 +464,16 @@ bool Parcel::enforceInterface(const String16& interface,
|
|||||||
if (threadState == NULL) {
|
if (threadState == NULL) {
|
||||||
threadState = IPCThreadState::self();
|
threadState = IPCThreadState::self();
|
||||||
}
|
}
|
||||||
threadState->setStrictModePolicy(strictPolicy);
|
if ((threadState->getLastTransactionBinderFlags() &
|
||||||
|
IBinder::FLAG_ONEWAY) != 0) {
|
||||||
|
// For one-way calls, the callee is running entirely
|
||||||
|
// disconnected from the caller, so disable StrictMode entirely.
|
||||||
|
// Not only does disk/network usage not impact the caller, but
|
||||||
|
// there's no way to commuicate back any violations anyway.
|
||||||
|
threadState->setStrictModePolicy(0);
|
||||||
|
} else {
|
||||||
|
threadState->setStrictModePolicy(strictPolicy);
|
||||||
|
}
|
||||||
const String16 str(readString16());
|
const String16 str(readString16());
|
||||||
if (str == interface) {
|
if (str == interface) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user