DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.62k stars 556 forks source link

Support cross-arch execve from ARM to AArch64 and vice versa #3537

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, I'm currently working on an "Android on Android" project which aims to provide a separate Android environment inside an app. We've run into some problems on 64-bit Android builds because many system binaries & other apps are still targeting 32-bit but 64-bit build of DynamoRIO cannot handle them (ERROR: Target process is for the wrong architecture). What's the possible solution here other than shipping 32-bit Android binaries & support only 32-bit apps?

hgreving2304 commented 5 years ago

Somebody here please correct me if what I am saying is not true, but I don't know of any ability to switch ARM and AArch64 in DynamoRIO e.g. like an Android kernel can. DynamoRIO is attached to a process in user space. I hope this is what you were asking and somebody please jump in if I missed something. Thanks

On Thu, Apr 11, 2019 at 10:11 PM cra10 notifications@github.com wrote:

Hi, I'm currently working on an "Android on Android" project which aims to provide a separate Android environment inside an app. We've run into some problems on 64-bit Android builds because many system binaries & other apps are still targeting 32-bit but 64-bit build of DynamicRIO cannot handle them (ERROR: Target process is for the wrong architecture). What's the possible solution here other than shipping 32-bit Android binaries & support only 32-bit apps?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DynamoRIO/dynamorio/issues/3537, or mute the thread https://github.com/notifications/unsubscribe-auth/ApX4ddwGtd21hqiNSOpCt6HWzEZHCFWbks5vgBWcgaJpZM4crVza .

derekbruening commented 5 years ago

First, this sems like more of a question for the users list https://groups.google.com/forum/#!forum/DynamoRIO-Users, rather than a specific bug that should be filed in the issue tracker. Next time please send an email to the list for a question.

Second, please provide more information on how exactly each type of app is being launched. Are we just talking an execve of a new binary? Or something else? Certainly mixing 32-bit ARM and 64-bit AArch64 in the same process is not at all supported by DR (unlike x86 where DR does have some support for mixing). However, for a process of one type doing an execve of a binary file of the other type, that would be fairly easy to support: what happens today is that DR inserts its own binary path into the execve. DR would just need to know where the proper DR binary is for the target file's architecture. E.g., today for x86 DR supports a 32-bit process doing an execve of a 64-bit process, and vice versa, by pointing at the other DR binary in the execve (making assumptions on the path layout, yes).

Carrotman42 commented 5 years ago

Edit: sorry for the noise, my email client didn't join the messages in this thread so I didn't see the updates from others until after I hit send.

ghost commented 5 years ago

Thanks for the info, I won't post this kind of (stupid) questions here anymore :P I'll try the "hooking execve" approach

derekbruening commented 5 years ago

The code figuring out whether to use a 64-bit or 32-bit DR path is here: https://github.com/DynamoRIO/dynamorio/blob/master/core/unix/os.c#L5617 You would just have to ensure the dynamorio_alt_arch_path is set up properly. Since we do not provide any single release package that includes both ARM and AArch64 there is no support today for finding the other one. If you end up adding a runtime option or some other mechanism to set it, please consider contributing a PR. In fact maybe we should keep this issue open for that feature request.