Skip to content

Added and some fixes - #141

Closed
xm999n wants to merge 8 commits into
JingMatrix:masterfrom
xm999n:master
Closed

Added and some fixes#141
xm999n wants to merge 8 commits into
JingMatrix:masterfrom
xm999n:master

Conversation

@xm999n

@xm999n xm999n commented Jun 8, 2026

Copy link
Copy Markdown

No description provided.

@JingMatrix

Copy link
Copy Markdown
Owner

Thanks for your interest in contributing. It seems to me that only the SELinux leak bypass worth a technical discussion. There are two issues in your solution:

  1. Java method hooking via JNI method overriding is detectable, and we seems to have to keep libzygisk.so in memory for your hooks to work properly.
  2. Java layer hook can be bypass by calling native function in libselinux.so directly.

Due to these problems, it is better that you implement the hiding strategy as a Zygisk module.

# Conflicts:
#	loader/src/common/daemon.cpp
@xm999n
xm999n force-pushed the master branch 2 times, most recently from 1d2ef16 to f70eb8a Compare August 4, 2026 16:01
Anonymous added 2 commits August 6, 2026 20:19
Hook libcore.io.Linux.write in app_zygote-derived processes and fake
EINVAL when the payload is exactly 'u:r:adbroot:s0', forcing the
detector's i.c() fallback path to return false so 'found adb_root'
is never reported. Fast path is a single integer compare per Os.write.
The previous hook called FindClass/GetMethodID on every matching Os.write,
which dominates the cost of the write and can contend on the class-loading
lock. app_zygote's ZygotePreload issues many Os.write calls during init;
under contention this stalled init past the detector's 5s
bindIsolatedService timeout, surfacing as 'Service connection timedout,
app zygote crashed?'.

Fixes:
- Resolve ErrnoException class + ctor ONCE in hook_os_write and pin as
  GlobalRefs (cached in atomics), valid for process lifetime and across
  the zygote->app_zygote fork.
- Remove FindClass('[B') + IsInstanceOf on the hot path: writeBytes'
  Object arg is, by libcore.io.Linux contract, always a byte[].
- Add thread_local reentrancy guard as cheap insurance against any
  indirect Os.write triggered by JNI internals.

Hot path now: one length dispatch + (only on the rare 15/33-byte match)
a bounded GetByteArrayRegion + memcmp. No FindClass, no class lock.
@JingMatrix

Copy link
Copy Markdown
Owner

KernelSU has integrated such hiding into its source. NeoZygisk shouldn't take the burden of fixing this leakage.

@JingMatrix JingMatrix closed this Aug 8, 2026
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.

2 participants