Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/com/scr01/scroot/RootFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object RootFlow {
"libbootstrap.so" to "e81028efeaf44aba81607aa6116cc1273ad8f4d4eee4ec58ff5e14be061fca90",
"libmemprep.so" to "a743f6c5432ec8072faa1bc47e07d8811135905eb3e458e8f4d892b192cadcee",
"libksud.so" to "637676421190aeec504093707ad675a45faaf11bd4b53129d52e150490902cca",
"libksuglue.so" to "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9",
"libksuglue.so" to "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30",
"libksucheck.so" to "0abb36169ff0864ee659e5b40f7666b01cf36d765e3216d9a4d14695f92817d6",
"libadbroot.so" to "5562adc1e5c6f52fb91f469a1a7d3480050d8697fb5dedbd7fb386d282cd88b8",
"manager.apk" to "80a9e4b1ba9644f361add3e003e1075bd4f9cb374bbde465c2b57522b5288ba9",
Expand Down
Binary file modified app/src/main/jniLibs/arm64-v8a/libksuglue.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ docker run --rm --platform linux/amd64 \
make -C /ksrc/linux-4.14.186 M=/work ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules
cp /work/ksu_glue.ko /out/ksu_glue.unpatched.ko
python3 /source/kernel/patch_init_offset.py /out/ksu_glue.unpatched.ko /out/ksu_glue.ko
echo "0a37c39e94f816b7c769efa583e0134d4e3331a38d6c93a926b9373229e70ebd /out/ksu_glue.unpatched.ko" | sha256sum -c -
echo "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9 /out/ksu_glue.ko" | sha256sum -c -
echo "2d18d4e6701337933add123ef01f4dceb151dfbe71e6f9f7dce7f512a21bad2d /out/ksu_glue.unpatched.ko" | sha256sum -c -
echo "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30 /out/ksu_glue.ko" | sha256sum -c -
'
19 changes: 17 additions & 2 deletions corresponding-source/KernelSU-Next-SCR01/kernel/ksu_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,21 @@ static bool ksu_is_root_helper(void)
*(u32 *)(sec + 4) == shell_sid_cache;
}

/*
* init launches several HALs as UID 0 and lets their executable select the
* SELinux domain. Refreshing those children with a kernel credential erases
* init's pending exec transition; wpa_supplicant then stays in shell:s0 and
* hwservicemanager refuses its HIDL registration. Only root helpers need the
* driver-fd/bootstrap refresh. Leave init and its service children untouched.
*/
static bool ksu_prepare_root_exec(void)
{
if (dev_uid() != 0)
return false;
ksu_resolve_sids();
return !ksu_is_current_domain(init_sid_cache);
}

/* Disable seccomp mode and drop TIF_SECCOMP for the current exec task. Android
* seccomp-bpf filter that SIGSYSes disallowed syscalls (notably __NR_reboot, KSU's
* supercall transport) BEFORE the syscall reaches our sys_call_table hook. KSU-Next
Expand Down Expand Up @@ -2309,7 +2324,7 @@ static long hook_execve(const char __user *filename,
* reboot(2) fallback, which inherited app seccomp kills before our
* syscall-table hook can see it.
*/
if (enable_manager_fd && dev_uid() == 0) {
if (enable_manager_fd && ksu_prepare_root_exec()) {
/*
* A task rooted by the temporary sel_read_enforce payload still
* owns its original untrusted_app cred/security blob. Replace it
Expand Down Expand Up @@ -2410,7 +2425,7 @@ static long hook_execveat(int dfd, const char __user *filename,
ksu_disable_seccomp();
stat_manager_child_seccomp++;
}
if (dev_uid() == 0) {
if (ksu_prepare_root_exec()) {
if (!root_helper) {
long refresh_rc = ksu_escalate_current();
if (refresh_rc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from elftools.elf.relocation import RelocationSection


EXPECTED_INPUT = "0a37c39e94f816b7c769efa583e0134d4e3331a38d6c93a926b9373229e70ebd"
EXPECTED_OUTPUT = "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9"
EXPECTED_INPUT = "2d18d4e6701337933add123ef01f4dceb151dfbe71e6f9f7dce7f512a21bad2d"
EXPECTED_OUTPUT = "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30"


def digest(data: bytes) -> str:
Expand Down
8 changes: 4 additions & 4 deletions corresponding-source/SOURCE_SHA256SUMS
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
7881e2c64cd44626665d4876c8cbf1ed5808a4069afd611945b4c7a7437c5aef KernelSU-Next-SCR01/kernel/Kbuild
56de7d6d82bfe0c830ea25598a8f7f34dea6436d2a1ac22e6e4eeaad214193b5 KernelSU-Next-SCR01/kernel/adb_root_toggle.c
0d50dd4bd6853bbeb20528066032ad1148d824aecf3b31624bbf845a25876894 KernelSU-Next-SCR01/kernel/build-in-docker.sh
931f24750aacbb3424ce3adc67b5e335d40bf949ce0781c53ff08456fcd40e60 KernelSU-Next-SCR01/kernel/build-in-docker.sh
bb1abef0939942dc644ad4a21ae71fe173c3e4b09e73ce89924ae4d1c1be0191 KernelSU-Next-SCR01/kernel/device.config
e0e46baf28b3220a981a924e546a9f81c6a4ba6ac2f4e2798ab4faa8ef201de1 KernelSU-Next-SCR01/kernel/ksu_glue.c
86a8b66a34d7de195bdd7e0b6ee3c36a64b2d7f27de1835e485d421fc9d6b8fa KernelSU-Next-SCR01/kernel/patch_init_offset.py
0c3ce72f36f154680274435dfb80234f76e2376e1ab7fc8a1152415adfb883ab KernelSU-Next-SCR01/kernel/ksu_glue.c
231cc98c698c7315ec05e2f0f45cf3fdbe56bea41a453c5b8c8e32d6c64bfb5d KernelSU-Next-SCR01/kernel/patch_init_offset.py
c90578d0ff4a2cd37c5cf77fb747f5c36f1a5c931572f648dd927cfef4c73320 KernelSU-Next-SCR01/manager/build-unsigned.sh
548c31f299860244b0eac032f2fc094c50bff095fd17e6ca9fb8cb2636a9071b KernelSU-Next-SCR01/manager/patch_manager.py
835c777cb09afeadf9d7e323cb165b97d179edc190c890bbe260a8283edcd395 KernelSU-Next-SCR01/manager/patch_source.py
Expand All @@ -21,4 +21,4 @@ ccf90fbd6dd5b5f40204b0fbbfc8db5d2540fd0a6d0939a2dec70f43282c490c upstream/meta-
df4b4a33c9974eb873e62ad01fa7229e9648cc848d032f6192a89b055cb9528c ../app/src/main/assets/meta-overlayfs-scr01.zip
5562adc1e5c6f52fb91f469a1a7d3480050d8697fb5dedbd7fb386d282cd88b8 ../app/src/main/jniLibs/arm64-v8a/libadbroot.so
637676421190aeec504093707ad675a45faaf11bd4b53129d52e150490902cca ../app/src/main/jniLibs/arm64-v8a/libksud.so
b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9 ../app/src/main/jniLibs/arm64-v8a/libksuglue.so
b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30 ../app/src/main/jniLibs/arm64-v8a/libksuglue.so
56 changes: 56 additions & 0 deletions docs/rooted-wifi-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Rooted Wi-Fi STA failure on SCR01 AVK2

Related: https://github.com/hackintoanetwork/SCRoot/issues/8

## Cause

Both `hook_execve` and `hook_execveat` refresh every UID-0 process when
`enable_manager_fd` is enabled. This includes init's newly forked service
children. `ksu_escalate_current()` replaces their credentials and selects
`u:r:shell:s0`, discarding the SELinux exec transition prepared by init.

The vendor supplicant starts as root before dropping to UID 1010. After
rooting, it therefore remains in `u:r:shell:s0` rather than
`u:r:hal_wifi_supplicant_default:s0`. Its HIDL registration fails with:

```text
Service android.hardware.wifi.supplicant@1.3::ISupplicant/default must be in VINTF manifest in order to register/get.
Failed to register as service supplicant interface with HIDL status: -2147483648
```

The VINTF declaration is already present. Wi-Fi HAL and wlan0 initialization
succeed, but WifiNative times out waiting for the supplicant and disables STA.

## Change

Skip root credential refresh and driver-FD injection for tasks still in the
init domain in both exec hooks. Init can then perform the normal executable
domain transition. Existing manager and su helper handling remains active.

The bundled module, its runtime integrity pin, the relocation patch pins,
and corresponding-source manifests are updated together.

## Validation

On an SCR01 running SCR01KDU1AVK2, the original module reproduced the failure.
Temporarily disabling `enable_manager_fd` only while restarting supplicant
restored its correct domain and allowed STA to connect; the parameter was
then restored to `Y`.

The original source was rebuilt in Ubuntu 20.04 with GCC 9.4.0, Linux
4.14.186, the checked-in device configuration, and the documented paths.
Its unpatched SHA-256 matched the release pin exactly:
`0a37c39e94f816b7c769efa583e0134d4e3331a38d6c93a926b9373229e70ebd`.
The modified source was built in the same environment and reproduced the
new module pins on a second build.

Both payload verifiers and all 76 Python tests pass. Android JVM unit tests
and lint also pass.

The rebuilt module was then installed and loaded by automatic rooting after
a reboot with Wi-Fi disabled. With `enable_manager_fd=Y`, two separate
disable/enable cycles started fresh supplicant processes in
`u:r:hal_wifi_supplicant_default:s0`; both connected to an existing AP and
Android reported the network as `VALIDATED`. Root access remained available
and the automatic setup completed successfully. No VINTF or vendor Wi-Fi
binary changes were needed.
12 changes: 6 additions & 6 deletions tools/verify_corresponding_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"upstream/meta-overlayfs-v1.3.1.tar.gz": "ccf90fbd6dd5b5f40204b0fbbfc8db5d2540fd0a6d0939a2dec70f43282c490c",
"KernelSU-Next-SCR01/kernel/Kbuild": "7881e2c64cd44626665d4876c8cbf1ed5808a4069afd611945b4c7a7437c5aef",
"KernelSU-Next-SCR01/kernel/adb_root_toggle.c": "56de7d6d82bfe0c830ea25598a8f7f34dea6436d2a1ac22e6e4eeaad214193b5",
"KernelSU-Next-SCR01/kernel/build-in-docker.sh": "0d50dd4bd6853bbeb20528066032ad1148d824aecf3b31624bbf845a25876894",
"KernelSU-Next-SCR01/kernel/build-in-docker.sh": "931f24750aacbb3424ce3adc67b5e335d40bf949ce0781c53ff08456fcd40e60",
"KernelSU-Next-SCR01/kernel/device.config": "bb1abef0939942dc644ad4a21ae71fe173c3e4b09e73ce89924ae4d1c1be0191",
"KernelSU-Next-SCR01/kernel/ksu_glue.c": "e0e46baf28b3220a981a924e546a9f81c6a4ba6ac2f4e2798ab4faa8ef201de1",
"KernelSU-Next-SCR01/kernel/patch_init_offset.py": "86a8b66a34d7de195bdd7e0b6ee3c36a64b2d7f27de1835e485d421fc9d6b8fa",
"KernelSU-Next-SCR01/kernel/ksu_glue.c": "0c3ce72f36f154680274435dfb80234f76e2376e1ab7fc8a1152415adfb883ab",
"KernelSU-Next-SCR01/kernel/patch_init_offset.py": "231cc98c698c7315ec05e2f0f45cf3fdbe56bea41a453c5b8c8e32d6c64bfb5d",
"KernelSU-Next-SCR01/manager/build-unsigned.sh": "c90578d0ff4a2cd37c5cf77fb747f5c36f1a5c931572f648dd927cfef4c73320",
"KernelSU-Next-SCR01/manager/patch_manager.py": "548c31f299860244b0eac032f2fc094c50bff095fd17e6ca9fb8cb2636a9071b",
"KernelSU-Next-SCR01/manager/patch_source.py": "835c777cb09afeadf9d7e323cb165b97d179edc190c890bbe260a8283edcd395",
Expand All @@ -38,7 +38,7 @@
"../app/src/main/assets/meta-overlayfs-scr01.zip": "df4b4a33c9974eb873e62ad01fa7229e9648cc848d032f6192a89b055cb9528c",
"../app/src/main/jniLibs/arm64-v8a/libadbroot.so": "5562adc1e5c6f52fb91f469a1a7d3480050d8697fb5dedbd7fb386d282cd88b8",
"../app/src/main/jniLibs/arm64-v8a/libksud.so": "637676421190aeec504093707ad675a45faaf11bd4b53129d52e150490902cca",
"../app/src/main/jniLibs/arm64-v8a/libksuglue.so": "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9",
"../app/src/main/jniLibs/arm64-v8a/libksuglue.so": "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30",
}
EXPECTED_MANAGER_INNER = {
"lib/arm64-v8a/libadbroot.so": "5562adc1e5c6f52fb91f469a1a7d3480050d8697fb5dedbd7fb386d282cd88b8",
Expand All @@ -47,8 +47,8 @@
}
EXPECTED_META_BINARY = "04ef286eb33dd6650be08c368cc16d06e369aeae2c582f8df520d0a7dcc2fa95"
EXPECTED_KERNEL_OUTPUTS = {
"ksu_glue.unpatched.ko": "0a37c39e94f816b7c769efa583e0134d4e3331a38d6c93a926b9373229e70ebd",
"ksu_glue.ko": "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9",
"ksu_glue.unpatched.ko": "2d18d4e6701337933add123ef01f4dceb151dfbe71e6f9f7dce7f512a21bad2d",
"ksu_glue.ko": "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30",
}
ORIGINAL_COMPONENT = b"#/com.rifsxd.ksunext.ui.MainActivity\x00"
PATCHED_COMPONENT = b"#/com.rifsxd.ksunext.ui.MainActivit_\x00"
Expand Down
2 changes: 1 addition & 1 deletion tools/verify_release_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
NATIVE / "libexploit.so": "86a8a98029e913b16abf5480bcecf8fe036cb0339de9c7b91dc5c0749898dece",
NATIVE / "libksucheck.so": "0abb36169ff0864ee659e5b40f7666b01cf36d765e3216d9a4d14695f92817d6",
NATIVE / "libksud.so": "637676421190aeec504093707ad675a45faaf11bd4b53129d52e150490902cca",
NATIVE / "libksuglue.so": "b1f6b9afbbfc2f6c388dada781f0761899f494bc6f05e8657fa4325b5a0cbfd9",
NATIVE / "libksuglue.so": "b0789adf40150a9ee22c5d4a62efa4ee5dae94a753a5250e0db669498c069c30",
NATIVE / "libmemprep.so": "a743f6c5432ec8072faa1bc47e07d8811135905eb3e458e8f4d892b192cadcee",
NATIVE / "librootsh.so": "77cfc2e1e8fd710cb18b442f950a76b63e0e0f30214c1131aed49d8ff85edc04",
}
Expand Down