Repository navigation
kernel: fix raw find_user callsite patching - #17
Merged
Merged
Conversation
Resolve the hook body for both internal callsite scans. With Clang CFI, the function pointer can instead refer to a jump table entry. Call find_user through an assembly stub in modules so the compiler preserves its return value across the runtime patch. Built-in builds can call find_user directly.
Collaborator
|
shut up on the self-recursive hook being removed by clang, its literally attributed. |
This reverts commit 1a10e7c.
Collaborator
|
@JoyElliot try 98abc85 |
Contributor
Author
Sorry the PR didn’t meet your expectations. I tested 98abc85 on my device and confirmed that the raw hook initialized successfully without falling back to Kprobes. Thank you very much for your contribution. |
Collaborator
no worries, I'll add you as reported by |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a Redmi Note 12 Turbo (
marble,5.10.271-android12), the raw hook failed during initialization and fell back to Kprobes:With Clang CFI, taking the address of
gphook_find_usercan yield a jump-table entry. The second scan starts there and misses the call togp_free_uidin the function body. Reuse the resolved body address for both scans.The self-recursive placeholder also lets Clang discard the result of the call that will be redirected to
find_user. Use a separate assembly stub so the hook preserves the returned pointer and releases its reference when filtering.After the fix, the same device patched all four syscall callsites and logged:
Built all eight ARM64 DDK targets locally. On
marble, the four priority syscalls matched the original Kprobe behavior for the tested application UIDs. Same-UID operations succeeded, cross-UID lookups succeeded with seccomp disabled, and cross-UID operations returnedESRCHwith seccomp enabled.