Rooting stock Android emulators with KernelSU, without touching the kernel
Per-AVD kernelsu.ko builds that root stock x86_64 Android Studio images from Android 13 to 17, with KernelSU, KernelSU-Next or FinaSU.
KernelSU / KernelSU-Next / FinaSU LKM for Android Studio AVDs (x86_64)
On this page
- Why the upstream modules don’t just work
- Supported emulator images
- Rooting an emulator
- 1. Get the tool
- 2. See your emulators and their kernels
- 3. Patch into a separate ramdisk
- 4. Cold boot with it
- Things that will trip you up
- A bug that would show up about once in 32,768 boots
- FinaSU support
- A web GUI, if you’d rather click
- Starting it
- A typical first run
- Locked down, because it runs commands
- Or one script on Windows
- SUSFS preview
- Credits
Testing root modules on a physical phone is slow: flash, reboot, wait, repeat. An Android Studio emulator is far quicker to wipe and rebuild, but getting KernelSU onto one has usually meant swapping the emulator’s kernel for a custom GKI build.
avd-kernelsu-x86_64-MultiSU takes a different route. It keeps the stock kernel and patches only the system image’s ramdisk.img, so that kernelsu.ko gets loaded at boot (KernelSU’s LKM mode). It works with three root solutions: KernelSU, KernelSU-Next and FinaSU.
Why the upstream modules don’t just work
KernelSU attaches prebuilt kernel modules to every release, so why not load one of those?
On arm64 phones, GKI kernels promise a stable Kernel Module Interface: a module built for one KMI generation loads on any kernel of that generation. x86_64 GKI kernels make no such promise. The upstream modules are built from the latest DDK source, and on emulator kernels they either refuse to load (Android 14) or trip kCFI and panic the kernel (Android 15).
So this project builds kernelsu.ko separately for each emulator kernel, from exactly what that kernel was built from:
- the
kernel/commonrevision named in that kernel’s Android CI build manifest - the kernel’s own config, read straight out of
kernel-ranchu(the images are built withCONFIG_IKCONFIG=y, so the config is embedded in the kernel) - the matching DDK clang
Supported emulator images
| Android | Kernel | Build ID |
|---|---|---|
| 13 (API 33) | 5.15.119-android13-8 |
10871489 |
| 14 (API 34) | 6.1.23-android14-4 |
9964412 |
| 15 (API 35) | 6.6.30-android15-8 |
11987101 |
| 16 (API 36.0) | 6.6.66-android15-8 |
13070261 |
| 16 QPR (API 36.1) | 6.12.38-android16-5 |
13996879 |
| 17 (API 37.0, and API 37.2 with 16 KB pages) | 6.12.81-android16-6 |
16167562 |
| 17 (API 37.1, 16 KB pages) | 6.12.69-android16-6 |
15053784 |
These are x86_64 google_apis_playstore images at their latest SDK revision. Other variants of the same API level (google_apis, default, -extNN) can ship a different kernel. The patch tool refuses any kernel it doesn’t have a module for, rather than guessing.
Rooting an emulator
Everything goes through one file, avd-ksu.py, which needs only Python 3.8+ and its standard library.
1. Get the tool
curl -LO https://github.com/imkamaran/avd-kernelsu-x86_64-MultiSU/releases/latest/download/avd-ksu.py
On Windows:
Invoke-WebRequest https://github.com/imkamaran/avd-kernelsu-x86_64-MultiSU/releases/latest/download/avd-ksu.py -OutFile avd-ksu.py
2. See your emulators and their kernels
python avd-ksu.py list
3. Patch into a separate ramdisk
# KernelSU, latest release
python avd-ksu.py patch --avd API35-GAPPS --out ksu-API35.img
# or pin a variant and version
python avd-ksu.py patch --avd API35-GAPPS --variant kernelsu-next --version v3.4.2 --out ksun-API35.img
python avd-ksu.py patch --avd API35-GAPPS --variant finasu --version v1.5.0 --out fina-API35.img
The first run downloads the kernelsu.ko for your kernel, plus the ksud and ksuinit binaries for your computer, from the repository’s releases. It checks them against SHA256SUMS and caches them in ~/.cache/avd-ksu.
Why --out? The SDK’s ramdisk.img is shared by every emulator that uses the same system image. Writing the patched copy to its own file leaves the SDK untouched, so rooted and stock emulators can live side by side, and undoing it is just booting without -ramdisk. (Patching the SDK ramdisk in place also works, and avd-ksu.py restore puts the original back.)
4. Cold boot with it
emulator -avd API35-GAPPS -ramdisk ksu-API35.img -no-snapshot-load
Install and open the manager APK of the same version you patched with, close the emulator, and start it again with the same command. The manager should now show Working (LKM), and apps can request root.
Things that will trip you up
- “Nothing happened.” Usually Quick Boot: a snapshot saved before patching resumes the old, unrooted system, and the patched ramdisk is never read. Keep
-no-snapshot-loaduntil root works. - Starting from Device Manager boots the stock ramdisk. Android Studio doesn’t pass
-ramdisk, so you get no root (and nothing breaks). Start the rooted emulator from the command line. uname -rdoesn’t change. The kernel is still stock, and the module hides itself from/sys/moduleandlsmod. Check root withadb shell su -c idinstead.adb shell suis denied until you grant the Shell app in the manager. Add--allow-shellwhen patching to allow it from the start.- Restart, don’t reboot. Android Emulator 37.2.13 on Windows can crash or hang during an in-guest reboot (
adb rebootor the power menu), rooted or not. - 16 KB page-size images. KernelSU-Next v3.4.2’s manager ships
libksud.sowithout 16 KB-aligned segments, soksudnever gets installed. The module itself loads fine. KernelSU v3.3.1 works. - Updated the system image? Run
patchagain. A new image revision can bring a new kernel. - API 36.1 with LSPosed or Zygisk needs at least 4096 MB of RAM for the emulator.
A bug that would show up about once in 32,768 boots
The most interesting fix in the build is for a bug you would almost never see.
On x86_64 kernels 6.2 and newer, module_finalize() scans a module for kCFI caller sequences. If it finds 41 ba or eb 0c 14 bytes in front of an indirect call, it treats the next four bytes as a kCFI type hash and rewrites them.
In front of a __nocfi call, those bytes aren’t a kCFI sequence. They’re just whatever code happens to sit there. In six places in KernelSU, they come from a relocation, so they depend on where in memory the module was loaded. In ksu_hook_execve_common(), an unlucky load address (estimated at no more than 1 in 32,768) would make the kernel corrupt the code right before the call to the original execve.
The fix, x86_64-kcfi-icall-trampoline.patch, routes every unchecked indirect call through a single noinline __nocfi trampoline, ksu_icall8(). Its call always has the same fixed bytes in front of it. CI also checks every built module and fails if any indirect call has bytes in front of it that the kernel could mistake for a kCFI sequence.
FinaSU support
My fork’s main addition is FinaSU, a KernelSU fork with kernel-level su, an overlayfs module system, a built-in Zygisk engine, a built-in Shizuku backend and SUSFS support. Its kernel code builds the same kernelsu.ko with the same x86_64 syscall dispatcher config, so it’s patched exactly like the other two. Two things needed extra work:
- Trusting the manager. CI reads the signing certificate of the official FinaSU manager APK from FinaSU’s release of the same version, and builds it into the module as a second trusted signature. Without that,
suworks but the FinaSU manager shows Not installed. A manager you build and sign yourself isn’t trusted. - 16 KB pages. FinaSU embeds a small “preinit” runner in
kernelsu.ko, which init executes when it switches to second-stage init. The runner was linked with the default 4 KB segment alignment, so on 16 KB page-size images the exec fails after its point of no return, PID 1 dies and the emulator boot-loops. Linking it with-z max-page-size=16384fixes it, and works on 4 KB kernels too. The build now fails if the runner ever has a segment aligned to less than 16 KB.
So far, root is confirmed on Android 17 (API 37.0): su -c id returns uid=0 ... context=u:r:ksu:s0 and the manager recognises the module. The 16 KB fix hasn’t been boot-tested yet, and Android 13 to 16 QPR builds pass the build checks but haven’t been booted.
A web GUI, if you’d rather click
The repo also comes with AVD Root Panel, a local web control panel for avd-ksu.py. It lists your emulators and their kernels, and lets you pick a root solution and version, patch, boot, check root and install the manager APK, all without typing a command.
It runs on Python’s built-in HTTP server, so there’s nothing to install. It also never re-implements anything: every patch, status, restore and SUSFS action runs avd-ksu.py itself, so the panel does exactly what the command line does. The full output of each action is shown in the page and saved under GUI/logs/.

Screenshots are from a demo setup with three example emulators: a supported one (Pixel 7, API 37.0), a 16 KB page-size image, and one whose kernel has no module. Click any screenshot to enlarge it.
Starting it
It needs Python 3.8+, the Android SDK (Emulator and Platform-Tools) and a clone of the repo, since it uses the avd-ksu.py one folder up.
- Windows: double-click
GUI\start-gui.bat - macOS / Linux:
./GUI/start-gui.sh - Anywhere:
python GUI/server.py --open
Then open http://127.0.0.1:8765/. Emulators started from the panel keep running after you stop it.
A typical first run
Select the emulator, choose the variant and version, and press Patch & boot. Install and open the manager of the same version with Install APK…, then Stop, Start again and Check root.
The page warns you before anything that can’t work: patching an emulator whose kernel has no module, KernelSU-Next on a 16 KB image, or patching in place, which roots every emulator that uses that system image.

Left to right: Check root with the live output of the patch, the kernel log filtered to KernelSU lines, and dark mode (it follows your system theme).
Locked down, because it runs commands
A web page that can run commands on your computer is an obvious target, so the panel is deliberately strict:
- It listens on
127.0.0.1only. - Every API request needs a random token, generated at each start and embedded in the page. The request’s
Host(andOrigin, when sent) must name the panel itself, so other websites can’t drive it through CSRF or DNS rebinding. - Inputs are checked against what actually exists (emulator names, variants, version format,
adbserials, images it made), and commands run without a shell. - The page loads nothing from other servers, enforced by a strict Content-Security-Policy.
Or one script on Windows
scripts/check-root.bat does the whole check in one go. It patches into a separate image, cold boots it, waits for the boot (or a kernel panic), and writes check-root.log and the full kernel log next to itself. Double-click it and pick an emulator, or pass the emulator, variant and version:
check-root.bat Pixel_7 finasu v1.5.0
SUSFS preview
kernelsu-next-susfs is a preview variant with an x86_64 port of SUSFS’s guard module. It hides paths fully on Android 15 to 17. On Android 13 and 14 it only partly works, because those kernels lack the IBT landing pads SUSFS’s syscall hooks need.
Credits
This is a fork of leemikepop/avd-kernelsu-x86_64, which built the per-emulator KernelSU and KernelSU-Next pipeline and the SUSFS preview. Thanks also to 5ec1cff’s write-up on KernelSU on AVDs, the x86_64 LKM work in KernelSU #3562 and #3570, nzaar9/avd-kernelsu, Ylarod’s DDK images, and LyraVoid for FinaSU.
The full details, including every patch and how CI builds each module, are in the README.