kernel: use rcu to access allowlist, refactor get allowlist api#3093
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the allow list API to optimize how the superuser count is retrieved. Instead of fetching the entire list of UIDs just to get the count, it introduces a dedicated getSuperuserCount() method that only returns the count. The API changes also introduce a more flexible allow list structure with support for paginated retrieval.
Key changes:
- Replaced direct
allowList.sizeaccess with a newgetSuperuserCount()native method - Refactored the kernel
ksu_get_allow_list_cmdstructure to use a flexible array member and separate count fields - Unified allow/deny list retrieval logic into a common
do_get_list_commonfunction with proper memory management
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt | Updated to call the new getSuperuserCount() method instead of accessing allowList.size |
| manager/app/src/main/java/me/weishu/kernelsu/Natives.kt | Removed the allowList property and added getSuperuserCount() external function |
| manager/app/src/main/cpp/ksu.h | Modified ksu_get_allow_list_cmd structure to use flexible array member and split count fields |
| manager/app/src/main/cpp/jni.cc | Replaced getAllowList() with getSuperuserCount() that only retrieves the total count |
| kernel/supercalls.h | Updated ksu_get_allow_list_cmd structure to match the userspace changes |
| kernel/supercalls.c | Refactored allow/deny list retrieval into common function with dynamic memory allocation |
| kernel/allowlist.h | Updated function signature to accept separate length and total count parameters |
| kernel/allowlist.c | Modified implementation to track both returned items and total count separately |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
991087e to
55f0d69
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ef91a7d to
8fc71fe
Compare
8fc71fe to
60e79e7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d2c087 to
a4df977
Compare
…n/KernelSU#3093) [cherry-picked from upstream commit: tiann/KernelSU@9f68f23] Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
…n/KernelSU#3093) [cherry-picked from upstream commit: tiann/KernelSU@9f68f23] Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
…n/KernelSU#3093) [cherry-picked from upstream commit: tiann/KernelSU@9f68f23] Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
…n/KernelSU#3093) [cherry-picked from upstream commit: tiann/KernelSU@9f68f23] Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
…lSU #3093) Port upstream KernelSU PR #3093 to fix GET_ALLOW_LIST buffer overflow (#3086) and align with the new allowlist API. Kernel (YukiSU): - allowlist: ksu_get_allow_list(array, length, out_length, out_total, allow) with RCU read lock and list_for_each_entry_rcu; exclude manager UID from returned list; perm_data gains rcu_head, list_add_tail_rcu / list_del_rcu / kfree_rcu for writers. - supercalls: add ksu_new_get_allow_list_cmd (count, total_count, uids[]), do_get_allow_list_common (kmalloc 128, copy_to_user) for old IOCTL, do_new_get_allow_list_common for new IOCTL; register NEW_GET_ALLOW_LIST / NEW_GET_DENY_LIST. Manager: - ksu.h/c: struct ksu_new_get_allow_list_cmd, get_superuser_count() using NEW_GET_ALLOW_LIST with count=0; keep get_allow_list for old API. - jni: getSuperuserCount() native; Natives.kt getSuperuserCount(); KsuCli uses getSuperuserCount() instead of allowList.size. HymoFS (sync): - Prefer ksu_get_allow_list() via kallsyms when available; fallback to reading /data/adb/ksu/.allowlist unchanged. Ref: tiann/KernelSU#3093 Cherry-picked from upstream: tiann/KernelSU@9f68f23 Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
…n/KernelSU#3093) [cherry-picked from upstream commit: tiann/KernelSU@9f68f23] Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
No description provided.