This repository was archived by the owner on Feb 12, 2026. It is now read-only.
Add new KernelSU method support#14
Merged
ThePedroo merged 8 commits intoThePedroo:masterfrom Nov 21, 2025
Merged
Conversation
ThePedroo
reviewed
Nov 8, 2025
Owner
ThePedroo
left a comment
There was a problem hiding this comment.
Though not critical, ksu_fd will leak here. It is best to close it if it exists, if anything.
ThePedroo
reviewed
Nov 8, 2025
daemon/src/main/jni/ksu.h
Outdated
| }; | ||
|
|
||
| struct ksu_uid_should_umount_cmd { | ||
| __u32 uid; // Input: target UID to check |
daemon/src/main/jni/denylist.cpp
Outdated
|
|
||
| return umount; | ||
| LOGD("KernelSU fd found, using the new method"); | ||
| struct ksu_uid_should_umount_cmd cmd = {}; |
daemon/src/main/jni/denylist.cpp
Outdated
| cmd.uid = app_uid; | ||
| syscall(SYS_ioctl, ksu_fd, KSU_IOCTL_UID_SHOULD_UMOUNT, &cmd); | ||
| LOGD("KernelSU new method, should umount for %d: %d", app_uid, cmd.should_umount); | ||
| return !!cmd.should_umount; |
Owner
There was a problem hiding this comment.
Use new lines to separate groups of code, like the log from syscall and return, as it is unrelated
daemon/src/main/jni/denylist.cpp
Outdated
| int version = 0; | ||
| int reply_ok = 0; | ||
|
|
||
| LOGD("KSU existence: try with old method"); |
|
|
||
| if (prepare_ksu_fd()) { | ||
| LOGD("KSU existence: try with new method"); | ||
| struct ksu_get_info_cmd g_version {}; |
Owner
There was a problem hiding this comment.
ditto (new line separation). Moreover, no need of the {}
| ); | ||
|
|
||
| LOGD("Prepare KSU fd: KSU fd: %x", ksu_fd); | ||
| return ksu_fd >= 0; |
daemon/src/main/jni/denylist.cpp
Outdated
| static int ksu_fd = -1; | ||
|
|
||
| static bool prepare_ksu_fd() { | ||
| LOGD("Prepare KSU fd: enter"); |
Owner
There was a problem hiding this comment.
Better to move it after the if, no?
daemon/src/main/jni/denylist.cpp
Outdated
Comment on lines
+151
to
+157
| if (!prepare_ksu_fd()) { | ||
| LOGD("KernelSU fd not found, falling back to the old method"); | ||
| bool umount = false; | ||
| int reply_ok = 0; | ||
| prctl((signed int)KERNEL_SU_OPTION, KERNELSU_CMD_UID_SHOULD_UMOUNT, app_uid, &umount, &reply_ok); | ||
| LOGD("KernelSU old method, should umount for %d: %d", app_uid, umount); | ||
| return umount; |
Collaborator
|
It still has debug logs and Its better we move to ksu.h |
Owner
I don't think so. I originally made this so that is is similar to ReZygisk's code, it is unnecessary to have a new file for such small thing, as we only need 2 CMDs for ioctl and 2 for prctl. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note that this PR keeps the old version support while adding the new one.