Historical lab journal. Commands and removal results below document past development only; they do not authorize current execution. Current policy forbids
ksud unload, direct removal ofkernelsuwithrmmod, and same-boot module replacement. Leave a loaded module resident until an ordinary reboot.
Date: 2026-07-11
Target: XPad2 ls12_mt8797_wifi_64, Android 13 /260, Linux
4.19.191+, OEM clang r383902.
Pinned KernelSU revision:
ccfee6dc67d79a1404eb71c67b67b4f6c7b65a4a
This is the first inspected official main revision containing the matching
ksud late-load command and its in-memory ksuinit::load_module path.
- Exact-target hello LKM loads and unloads on the device.
- KernelSU main has been ported far enough to compile and link a
kernel/kernelsu.kofor Linux 4.19 using the OEM config/toolchain. - The module is built in an explicit legacy mode:
CONFIG_KSU_LEGACY_4_19=yCONFIG_KSU_DISABLE_MANAGER=y- modern file-wrapper disabled/stubbed;
- modern SELinux policy clone/replace and SELinux-hide disabled/stubbed;
- legacy mode retains the exploit-provided permissive SELinux context;
- missing 4.19 helper names/types have guarded compatibility shims.
- The resulting module has 146 undefined kernel symbols.
- Installed OEM module
__versionsrecords cover 52/146 with no CRC conflict. - This is not the decisive constraint because
ksud late-loadusesksuinit::load_module, which rewrites undefined ELF symbols to absolute addresses from/proc/kallsymsbeforeinit_module. - Runtime kallsyms resolves 125/146 imported symbols.
The following 21 symbols are not visible in the runtime /proc/kallsyms and
therefore cannot be relocated by the official manual loader:
__cpu_online_mask
__tracepoint_sys_enter
arm64_const_caps_ready
cpu_hwcap_keys
cpu_hwcaps
handle_sepolicy
init_mm
init_pid_ns
init_task
kmalloc_caches
memstart_addr
mntns_operations
param_ops_bool
path_mount
path_umount
seccomp_filter_release
selinux_state
static_key_initialized
system_wq
tasklist_lock
tracepoint_srcu
Most are data symbols hidden because this OEM kernel does not expose all data
symbols through kallsyms. path_mount and path_umount are newer APIs absent
from 4.19. Loading the module before removing/replacing all 21 dependencies is
not allowed.
- Eliminate
param_ops_boolby hardcoding the legacy late-load shell policy and omitting legacy module parameters. - Stub the unused userspace sepolicy command (
handle_sepolicy) in legacy mode. - Replace/disable
path_mount,path_umount, mount-namespace and pre-5.9 umount functionality for the first late-load core test. - Remove policy-only
selinux_stateand seccomp internals from the legacy permissive path. - Audit the ARM64 syscall hook implementation. Its patch-memory path pulls in
init_mm,memstart_addr, CPU capability data, online-mask data and tracepoint state. Choose a 4.19-safe hook method that uses kallsyms-visible functions only; do not guess addresses for hidden data. - Rebuild and require 0 missing runtime symbols.
- Build
ksudfrom the same revision with the XPad2 module embedded as4.19.191+_kernelsu.ko(or a deliberately chosen--kmiasset name). - Only after static gates pass, run
ksud late-loadunder the existing temporary root and verify KSU UAPI/root/unload behavior.
KernelSU/kernel/kernelsu.koksu_imports.txtksu_imports_missing_runtime.txtruntime_kallsyms.txtoem_modules/- prior LKM ABI proof:
../xpad2_lkm_abi_20260711/VALIDATION_REPORT.md
The hard gate above is historical. The final legacy port has 93 imports and zero names missing from the target runtime kallsyms. The final artifacts are:
f7b5da52ca8ca138d33117788226c5d2fca3b8031a6f49fb85e3c33abd7b4ee1 kernel/kernelsu.ko
f7b5da52ca8ca138d33117788226c5d2fca3b8031a6f49fb85e3c33abd7b4ee1 userspace/ksud/bin/aarch64/xpad2-4.19.191_kernelsu.ko
3145acec98ba2b31f9b376f50ad139bbab3efd812613d595e2328843382959e0 target/aarch64-linux-android/release/ksud
The standalone and embedded module hashes are identical. On device boot ID
8e17d437-33c4-4bd8-9920-ffc0dfa3e112, with no KernelSU module initially
loaded, the following command was executed through the temporary root:
/data/local/tmp/ksud-xpad2 late-load --kmi xpad2-4.19.191It returned zero. The boot ID did not change, /proc/modules showed
kernelsu live, and the same ksud then reported:
version: 32547
flags: 0x5
uapi_version: 2
features: 0x5
lkm: true
late_load: true
runtime_mode: late-load
KernelSU's own ksud debug su (not the temporary exploit su) produced:
uid=0(root) gid=0(root)
Uid: 0 0 0 0
Gid: 0 0 0 0
CapEff: 0000003fffffffff
Key ARM64 legacy fixes were: correct ADRP immhi/immlo decoding; walking the
live TTBR1 page tables to obtain the actual syscall-table physical page;
fixmap write/readback verification; a direct reboot supercall hook for the
anonymous KSU driver fd; and preserving original syscall functions so direct
table adapters do not recurse.
The unload reboot is fixed and its cause is definitive. Live dmesg showed all five syscall entries restored with successful readback, all legacy adapters drained, and the module listed as last unloaded. The subsequent fault was:
pc: kernfs_remove_by_name_ns+0x78/0x90
The legacy module had called kobject_del(&THIS_MODULE->mkobj.kobj) during
init to hide itself. Normal module teardown then removed the same kernfs
object a second time. Legacy mode now leaves the module kobject registered so
the module core owns its single removal. In addition, the late-load
input_event kprobe is now unregistered according to recorded registration
state, and syscall adapters have an exit gate plus active-call drain.
On boot ID 88209a52-fc6f-48f5-a664-f2755c095b58, direct rmmod kernelsu
returned zero, the module disappeared, the boot ID stayed unchanged, and the
reboot magic syscall again returned the original EPERM. A second late-load
succeeded in the same boot.
The stock unload command's global Android stop/start sequence was also
the reason it previously disconnected ADB and risked watchdog reboot. The
exact XPad2 legacy target now uses a direct unload path. Device validation
showed ksud unload returning zero while boot ID stayed unchanged, the module
was removed, and both adbd and zygote remained running. A subsequent
same-boot late-load restored KernelSU version 32547, UAPI 2, and working
ksud debug su root.
The initial v0.1.0 artifacts deliberately used
CONFIG_KSU_DISABLE_MANAGER=y while the Linux 4.19 compatibility boundary was
being established. The product build now enables Manager integration. Its
remaining compile blocker was the newer fsnotify inode-event callback; the
target-guarded legacy adapter now supplies Linux 4.19's handle_event
signature and routes both API variants through the same bounded
packages.list name check.
The Manager-enabled module and the module embedded in its matching ksud are byte-identical:
a99d230975c70c7efe72142770f936cd5e7585cfdd6ba9c8d45807bdf87b3f13 artifacts/kernelsu-xpad2-4.19.191.ko
8e6fed9f063b9b998f5b0cec8b64f31ad1eea885c528b9e9883ff3f4cd108e06 artifacts/ksud-xpad2
Offline cargo fmt --check, cargo ndk check, clippy with warnings denied,
and release build passed for the matching source tree. Physical-device
validation loaded the module from an initially unloaded boot, retained SELinux
enforcing state, exposed KernelSU version 32547/UAPI 2, and the already
installed me.weishu.kernelsu Manager displayed working state. The loader did
not install or replace the Manager APK.
For provenance, the v0.1.0 Manager-disabled binaries remain under explicit
*-no-manager* names. Current generic artifact names refer to the
Manager-enabled build. Neither variant may be removed or replaced online;
leave a loaded module resident until an ordinary reboot.
v0.2.0 could identify the official Manager and expose a working driver fd to
its app process, but the Manager's libksud.so debug su performs an exec. The
inherited driver fd was closed at that boundary, after which its fallback
bootstrap syscall was rejected by the Android app seccomp filter with SIGSYS.
An early attempt to reuse the init SELinux domain was also invalid for this
firmware because the live policy explicitly denies init an
execute_no_trans path for shell_exec.
The v0.2.1 legacy path now:
- pins the Manager appId supplied by the trusted loader;
- installs a non-CLOEXEC driver fd only for the exact Manager
libksud.so debug subootstrap; - resolves the active 4.19
selinux_statethrough the mounted selinuxfs superblock instead of guessing a hidden KASLR-relative data address; - clones the active 4.19 flex-array policydb, adds the standard
ksuandksu_filetypes and rules off-lock, then swaps it under the OEMpolicy_rwlockand resets the AVC; - excludes the incompatible modern seccomp action-cache implementation.
The final module has 137 undefined runtime imports and all 137 names exist in
the target runtime kallsyms. Its vermagic is exactly
4.19.191 SMP preempt mod_unload modversions aarch64.
Final physical validation used an ordinary reboot into boot ID
552339f0-c1ad-4b3e-96c9-fbb6ae706c46. xpad2 0.1.4 rejected the first
holder round cleanly, obtained temporary root on adaptive round 2/6, and loaded
the module. The official Manager 32547 was then
force-stopped and cold-started again. Both launches completed its install,
debug-su and module-list calls without SIGSYS or Created process is not a shell. The resulting shell reported:
uid=0(root) gid=0(root) context=u:r:ksu:s0
SELinux status: Enforcing
Current product artifacts:
e930a6929c6cd156f394e6b15bed2258b19205cc17fa3410db7f68cef7b8fb21 artifacts/kernelsu-xpad2-4.19.191.ko
e930a6929c6cd156f394e6b15bed2258b19205cc17fa3410db7f68cef7b8fb21 userspace/ksud/bin/aarch64/xpad2-4.19.191_kernelsu.ko
26ea0f41af159a63a9afdff98963247da9d0bad0363f7e9c937f4cfbcd9f69c6 artifacts/ksud-xpad2