android: redirect init rc paths without overwriting buffers - #313
Open
xeropresence wants to merge 1 commit into
Open
xeropresence wants to merge 1 commit into
xeropresence wants to merge 1 commit into
Conversation
xeropresence
commented
Sep 19, 2026
| "on property:sys.boot_completed=1\n" | ||
| " exec -- " SUPERCMD " su -Z " MAGISK_SCTX " exec " APD_PATH " -s %s boot-completed\n" | ||
| " exec -- " SUPERCMD " su event boot-completed\n" | ||
| " exec -- " SUPERCMD " su -Z " MAGISK_SCTX " exec " APD_PATH " uid-listener &\n" |
Author
There was a problem hiding this comment.
APD already starts the UID listener from on_boot_completed() via
run_uid_monitor(). The rc block already invokes boot-completed, so
this separate startup command is redundant.
The trailing & is passed to APD as a literal argument here, not
interpreted by a shell. During the earlier GrapheneOS testing, replacing
this with exec_background produced two listeners. Removing the line
left one listener running—the one started by APD's boot-completed handler.
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.
Summary
Redirect init's
openatfilename through temporary userspace stack storage instead of overwriting the caller's filename allocation. Restore the syscall argument afterward without copying into the original buffer.Problem
The existing path tries to copy
/dev/user_init.rcover init's supplied filename. That replacement does not necessarily fit:/init.rcis shorter. The after-hook then restores an entire 64-byteORIGIN_RC_FILEStable entry, even though that table-entry size says nothing about the capacity of init's allocation.Those writes can corrupt userspace memory or fault on hardened configurations. The fallback also writes directly to
args->arg1, which is not the filename argument when a syscall wrapper suppliespt_regs.Changes
syscall_argn/set_syscall_argnso wrapper-based syscall hooks are handled correctly.apd uid-listener &rc command. Init passes&as a literal argument rather than shell backgrounding syntax, and APatch'sboot-completedhandler already starts the listener.The original filename buffer is never modified. A failed replacement-path copy leaves the original syscall argument in place, and the one-shot hook cleanup remains enabled. No GrapheneOS-specific feature disable or persistent preset-format change is introduced.
Verification
Built the Android ARM64 payload and
kptoolson this branch.Device testing used all three fixes on KernelPatch
0.13.8, with a Pixel 8 running GrapheneOS2026081300:/system/etc/init/hw/init.rc; the one-shot hook was removed.post-fs-data,services, andboot-completedexited with status0.apd uid-listenerprocess remained running.