pr: ptrace-based root
Weekend project: diving back into Linux chroot because I really wanted a native Linux environment on my phone! 💪📱
Everyone’s first thought is probably: "Just use Termux!"
Well, not quite. This journey actually started with me digging into virtualization, specifically the Android Virtualization Framework (AVF). Unfortunately, my current work phone (a Samsung powered by Snapdragon, huge thanks to Dicoding for the device 😍) doesn’t support AVF the way modern Google Pixels do. Waiting for it to arrive on this architecture feels like a long shot.
So, I shifted gears and got inspired by proot. It’s incredibly clever how it utilizes ptrace to intercept system calls and translate them on the fly, effectively creating a virtual root filesystem without needing actual root access. This is the exact magic Termux adapted to run various Linux distros on Android.
Bonus level unlocked 🔓: Navigating around Android's W^X (Write XOR Execute) restrictions. This security mitigation is notoriously known for keeping similar apps stuck at Target SDK 28. Finding a way to bypass this and bump it up to SDK 35 is an interesting challenge, especially if I ever decide to publish this on the Play Store.
For this weekend, the goal was to understand and implement proot without relying on the Termux environment—just wiring it up to a simple Android UI. Just for fun, I’m also porting a bunch of the initialization scripts into Rust 🦀 so I don’t have to rely too much on bash/mksh.
You can check out the mess/progress here: https://github.com/oonid/pr
Oh, and this whole deep dive suddenly made me fully grasp a brilliant article written by Yohanes Nugroho a year ago about using seccomp for syscall interception in Linux and Android. Everything just clicks now! 😁
Read it here: https://blog.compactbyte.com/2025/04/27/seccomp-untuk-intersepsi-syscall-di-linux-dan-android/
If pak Riza Satria (my lecturer) is still teaching Systems Programming, this could be a pretty fun use case for the class! 🧐
#AndroidDev #Linux #RustLang #SystemsProgramming #Termux #WeekendProject
(Cross-posted from LinkedIn)

