Skip to content

kernel: use rcu to access allowlist, refactor get allowlist api#3093

Merged
Ylarod merged 1 commit into
mainfrom
newallowlist
Feb 23, 2026
Merged

kernel: use rcu to access allowlist, refactor get allowlist api#3093
Ylarod merged 1 commit into
mainfrom
newallowlist

Conversation

@5ec1cff

@5ec1cff 5ec1cff commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@5ec1cff 5ec1cff linked an issue Dec 22, 2025 that may be closed by this pull request
3 tasks
@5ec1cff 5ec1cff requested a review from Copilot December 22, 2025 15:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.size access with a new getSuperuserCount() native method
  • Refactored the kernel ksu_get_allow_list_cmd structure to use a flexible array member and separate count fields
  • Unified allow/deny list retrieval logic into a common do_get_list_common function 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.

Comment thread kernel/supercalls.c Outdated
Comment thread kernel/supercalls.c Outdated
Comment thread kernel/allowlist.c Outdated
Comment thread manager/app/src/main/cpp/ksu.h
Comment thread kernel/supercalls.c
@5ec1cff 5ec1cff force-pushed the newallowlist branch 2 times, most recently from 991087e to 55f0d69 Compare December 22, 2025 17:50
@5ec1cff 5ec1cff requested a review from Copilot December 22, 2025 17:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c
Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c Outdated
Comment thread kernel/allowlist.c
Comment thread kernel/allowlist.c
@aviraxp aviraxp marked this pull request as ready for review December 23, 2025 10:47
@aviraxp aviraxp requested review from Ylarod and tiann December 23, 2025 10:47
@5ec1cff 5ec1cff changed the title new get allow list api kernel: use rcu to access allowlist, refactor get allowlist api Dec 23, 2025
@aviraxp aviraxp requested a review from Copilot December 23, 2025 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread kernel/allowlist.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread kernel/allowlist.c
Comment thread kernel/allowlist.c
@Ylarod Ylarod merged commit 9f68f23 into main Feb 23, 2026
17 checks passed
@Ylarod Ylarod deleted the newallowlist branch February 23, 2026 13:52
AlexLiuDev233 pushed a commit to ReSukiSU/ReSukiSU that referenced this pull request Feb 24, 2026
…n/KernelSU#3093)

[cherry-picked from upstream commit: tiann/KernelSU@9f68f23]

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
AlexLiuDev233 pushed a commit to ReSukiSU/ReSukiSU that referenced this pull request Feb 24, 2026
…n/KernelSU#3093)

[cherry-picked from upstream commit: tiann/KernelSU@9f68f23]

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
AlexLiuDev233 pushed a commit to ReSukiSU/ReSukiSU that referenced this pull request Feb 24, 2026
…n/KernelSU#3093)

[cherry-picked from upstream commit: tiann/KernelSU@9f68f23]

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
AlexLiuDev233 pushed a commit to ReSukiSU/ReSukiSU that referenced this pull request Feb 24, 2026
…n/KernelSU#3093)

[cherry-picked from upstream commit: tiann/KernelSU@9f68f23]

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
u9521 pushed a commit to u9521/KernelSU that referenced this pull request Feb 24, 2026
Anatdx added a commit to Anatdx/YukiSU that referenced this pull request Feb 25, 2026
…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>
linastorvaldz pushed a commit to linastorvaldz/VortexSU that referenced this pull request Mar 11, 2026
…n/KernelSU#3093)

[cherry-picked from upstream commit: tiann/KernelSU@9f68f23]

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer overflow in GET_ALLOW_LIST

3 participants