Skip to content

Restore the INET group patch on the manager's original gid array - #795

Open
JingMatrix wants to merge 1 commit into
masterfrom
fix-manager-inet-gid
Open

Restore the INET group patch on the manager's original gid array#795
JingMatrix wants to merge 1 commit into
masterfrom
fix-manager-inet-gid

Conversation

@JingMatrix

@JingMatrix JingMatrix commented Jul 27, 2026

Copy link
Copy Markdown
Owner

The manager runs inside com.android.shell, which has no INTERNET permission before Android 12, so we add the INET group ourselves during zygote specialization. We were patching only the gid array that the native specialization uses; the array Java keeps holding is the one Zygote#forkAndSpecialize reads a moment later to decide whether the process is allowed to use the network. It still said no, so every socket and DNS query inside the manager failed with EPERM, which surfaces as SecurityException: Permission denied (missing INTERNET permission?).

LSPosed patched both arrays ever since the parasitic manager was introduced, and I dropped that line while rewriting the module for the new zygisk architecture. Android 12 and later were never affected, because com.android.shell declares INTERNET there and the gid array already carries the group.

This is still a hypothesis until it is confirmed on a device. If it holds, it should also explain the empty Repository tab: the manager simply had no network at all.

Fixes #636

The parasitic manager lives inside com.android.shell, and uid 2000 has
no INTERNET permission before Android 12, so we grant it ourselves: the
zygisk module appends the INET group to the gid array in
preAppSpecialize.

That is enough for setgroups(), but not for everything. As soon as
nativeForkAndSpecialize returns, Zygote#forkAndSpecialize runs

    NetworkUtils.setAllowNetworkingForProcess(containsInetGid(gids));

against the array it passed in, which is not the one we substituted, so
it concludes that we have no network access. The flag it sets lives in
libnetd_client and gates the process from the inside: with it off,
dns_open_proxy() and socket() return EPERM whatever groups we really
belong to. getaddrinfo then falls back to local resolution, fails as
EAI_NODATA with errno EPERM, and libcore turns that into "Permission
denied (missing INTERNET permission?)". The unchecked SecurityException
kills the OkHttp dispatcher thread and the manager with it.

LSPosed patched the caller's array too, ever since the commit that
introduced the parasitic manager, and I dropped that one line while
rewriting the module for the new zygisk architecture. Nothing broke on
Android 12 and later because com.android.shell gained INTERNET there,
so the gid array already carries the group and our patching is
redundant. On Android 11 and below it is the only thing that works.

Fixes #636
@JingMatrix

Copy link
Copy Markdown
Owner Author

The history of this line, for the record:

  • 59cc621 (LSPosed PR 1103, September 2021) introduced the parasitic manager and the INET group patch together, and already patched both the new array and the caller's one.
  • 2d9d91b (LSPosed PR 1133) copied the same block into specializeAppProcessPre two days later, so the USAP path would behave the same way.
  • It survived the zygisk support in 7a7c0c5 and the bridge/loader split in e0de4ca, and was still there right before my refactor, in magisk-loader/src/main/jni/src/magisk_loader.cpp:142.
  • Refactor native modules and migrate to new Zygisk architecture #550 rewrote the block for the new zygisk architecture and kept only the half that fills the new array. preAppSpecialize covers both entry points now, so a single patch is enough, but it has to be the one Java can still see.

The line never carried a comment saying what it was for, which is probably why it looked redundant to me at the time. It has one now.

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.

[Android 11] Disabling DoH cause Vector manager to crash

1 participant