An experimental KernelSU late-load port for the exact Ruby firmware described below. It loads KernelSU at runtime without replacing the boot image.
To obtain the temporary root required by the loader on the verified firmware, see ABC00012345/ghostlock_ruby. That project implements the pure-C, host-assisted re-root stage; this project starts at the resulting authorized temporary-root boundary and installs the runtime KernelSU module.
This repository is based on upstream
xpad2-ksu-lateload commit
9af3e0ea817fcbdf45b9cb08fc8b9bd1910b1cc3 which is based off
KernelSU commit
ccfee6dc67d79a1404eb71c67b67b4f6c7b65a4a.
The port keeps the upstream GPL
license and adds a guarded Linux 4.19 compatibility path.
This port updates kernelsu commit to 7d7322f20b3163b254e90e81a67e0a6b9c1f0e77.
This for fork would not be possible without @ABC00012345 adaptation of the xpad2-ksu-lateload project and his patching scripts.
- Product/device:
ruby/Xiaomi Redmi Note 12 Pro 5G - SoC/kernel family: MediaTek MT6877TT, arm64-v8a
- Android: 14
- Kernel release:
4.19.191-ge6429b82e599 - Kernel vermagic:
4.19.191-ge6429b82e599 SMP preempt mod_unload modversions aarch64 - OEM compiler: Android clang
r383902 - ksud KMI selector:
ruby-4.19.191
This is an ABI-specific port. A matching model name alone is not sufficient: kernel build, firmware, symbol visibility and module ABI must match. Do not load the included module on unrelated devices or firmware revisions.
Some of the below info is outdated and stale.
Verified on physical hardware:
- late-load from an initially unloaded boot;
- KernelSU version 32547 and UAPI 2;
- KernelSU-provided root shell;
- Manager-enabled package observation on Linux 4.19;
- the official production-signed
me.weishu.kernelsuManager reporting working state and KernelSU version 32547 after a cold restart; - Manager bootstrap and root shells running in
u:r:ksu:s0while global SELinux remains Enforcing; - historical development validation also covered removal and same-boot reload.
The removal observations are retained only as historical evidence. Current
product and test policy forbids online removal or replacement of the loaded
module: do not execute ksud unload or remove kernelsu with rmmod. Leave
the module loaded until an ordinary reboot.
The current kernel module imports 137 runtime symbols, with zero missing from the verified target's runtime kallsyms.
- repository root: upstream KernelSU Git history plus the XPad2 port changes.
artifacts/: the exact binaries used for final device validation.PROGRESS.md: development history, root causes and validation evidence.
Build caches, OEM modules, full runtime kallsyms dumps and device-specific logs are intentionally excluded from this public-source copy.
Check releases for close to stable experience and check the actions for a buggy and sometimes even broken experience.
You need:
- the matching XPad2 vendor kernel source/configuration;
- Android clang
r383902; - an x86_64 Linux build environment;
- Rust with the
aarch64-linux-androidtarget; - Android NDK and
cargo-ndk.
The local validation used a Lima x86_64 VM because the OEM compiler is an x86_64 Linux binary. Paths below are examples; adjust them to your tree.
export PATH=/path/to/clang-r383902/bin:$PATH
make -C /path/to/vendor-kernel \
O=/path/to/kernel-out \
M="$PWD/kernel" \
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
CLANG_TRIPLE=aarch64-linux-gnu- \
LLVM_IAS=1 \
CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm \
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip \
CONFIG_KSU=m \
CONFIG_KSU_LEGACY_4_19=y \
KSU_VERSION=32547 \
KCFLAGS="-Wno-strict-prototypes -Wno-int-conversion \
-Wno-gcc-compat -Wno-missing-prototypes \
-Wno-declaration-after-statement -Wno-unused-function" \
modules -j"$(nproc)"Before building ksud, copy the resulting module to the embedded asset:
install -m 0644 kernel/kernelsu.ko \
userspace/ksud/bin/aarch64/xpad2-4.19.191_kernelsu.koexport ANDROID_NDK_HOME=/path/to/android-ndk
export KSU_VERSION_CODE=32547
export KSU_VERSION_NAME=0.2.1-xpad2
cargo ndk -t arm64-v8a check -p ksud
cargo ndk -t arm64-v8a clippy -p ksud -- -D warnings
cargo fmt --all -- --check
cargo ndk -t arm64-v8a build --release -p ksudThe result is
target/aarch64-linux-android/release/ksud.
You must already have authorized temporary root capable of loading a kernel module. Push ksud and invoke the exact KMI:
adb push artifacts/ksud-xpad2 /data/local/tmp/ksud-xpad2
adb shell chmod 755 /data/local/tmp/ksud-xpad2
adb shell /path/to/temporary-su -c \
"/data/local/tmp/ksud-xpad2 late-load --kmi xpad2-4.19.191"Do not pass --allow-shell: the XPad2 legacy module uses a guarded,
hard-coded shell policy and does not expose that module parameter.
Validate:
adb shell /data/local/tmp/ksud-xpad2 debug info
adb shell 'echo "id; exit" | /data/local/tmp/ksud-xpad2 debug su'Expected core fields:
version: 32547
uapi_version: 2
lkm: true
late_load: true
runtime_mode: late-load
Earlier development runs validated both the userspace removal path and direct kernel-module removal without changing the boot ID, followed by a same-boot reload. Those results remain useful as implementation-history evidence, but they are not current operating instructions.
The supported lifecycle is now load once and leave the module resident until an ordinary reboot. If a loaded module is mismatched, unhealthy, or needs to be replaced, stop and reboot; do not attempt online removal or replacement.
The port includes target-guarded solutions for:
- Linux 4.19 API and feature gaps;
- a Linux 4.19
fsnotifyevent adapter for Manager package observation; - dynamic
sys_call_tablediscovery fromel0_svc; - live TTBR1 page-table walking and fixmap writes with readback;
- direct legacy syscall adapters with preserved originals;
- reboot-supercall installation of the anonymous KSU driver fd;
- syscall adapter quiescing during unload;
- kprobe registration-state tracking;
- safe module kobject lifetime during unload.
See PROGRESS.md for the detailed failure analysis and hardware evidence.
Loading kernel modules and modifying syscall dispatch can crash the device or corrupt data. Keep a recovery path and backups. Use only on hardware you own or are explicitly authorized to test. This project is provided without warranty.
KernelSU and this derivative are distributed under GPL-2.0; see LICENSE and
the per-file SPDX headers. Upstream copyrights and history are retained in
the repository history.