Handle denied system DNS lookup in manager#771
Conversation
There was a problem hiding this comment.
Pull request overview
Defensively prevents Vector manager crashes on Android 11 when using OkHttp’s system DNS (DoH disabled) by converting unexpected SecurityException failures at the Dns.lookup() boundary into the checked UnknownHostException OkHttp expects.
Changes:
- Wrap
CloudflareDNS.lookup()resolution path in atry/catch. - Convert
SecurityExceptionfrom DNS lookup intoUnknownHostExceptionwith the original exception set as the cause.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- CI 构建流程优化 - PR JingMatrix#767: DEX 混淆加固 - PR JingMatrix#771: 修复 Android 11 DNS 崩溃 - PR JingMatrix#764: 修复更新检查 URL 及构建配置 - PR JingMatrix#761: dex2oat Wrapper + XmlUtils Stub - PR JingMatrix#748 + JingMatrix#579: EMUI/HarmonyOS 寄生管理器修复 - PR JingMatrix#750: 仓库源备份路由及手动选择 - Issue JingMatrix#773: daemon SQLite EACCES 崩溃兜底修复 - 杂项优化:daemon 状态、模块列表 UI、zygisk 脚本
…rix/vector JingMatrix#764: Fix update metadata URL and version checks JingMatrix#771: Handle denied system DNS lookup in manager JingMatrix#770: Add daemon process watchdog with crash rate-limiting (backoff disabled)
…L fix, DNS query fix, watchdog max-retry
Preserve the session-scoped DoH fallback from JingMatrix#765, and convert SecurityException only around the final system resolver call.
|
Thanks for taking a look at this. That said, I don't see anything here that points to the actual cause of #636, and the reporter hasn't been asked whether this helps — so there's no way to tell if it changes anything for them. I'd rather not merge a fix we can't confirm, so I'll close this for now. If the reporter tries it and it helps, happy to revisit. |
|
The CI build linked in #636 was produced by the Core workflow for this PR’s current head ( The Repository tab still does not load, so I’ve asked for targeted logs and network details in #636. I’ll treat that as a separate failure path rather than expanding this PR. Would you be open to reconsidering #771 based on the confirmed crash fix? |
Fixes #636
When DoH is disabled, or when the DoH resolver fails and falls back, the manager uses OkHttp's system DNS implementation through
CloudflareDNS.lookup(). The crash log in #636 shows Android 11 can throw an uncheckedSecurityExceptionfrom that DNS lookup path:FATAL EXCEPTION: OkHttp Dispatcherjava.lang.SecurityException: Permission denied (missing INTERNET permission?)at org.lsposed.manager.util.CloudflareDNS.lookup(...)The manifest already declares
android.permission.INTERNET, so this is not a manifest-permission fix. Instead, handle the denied lookup defensively around the final system resolver call by convertingSecurityExceptionintoUnknownHostException, which is the checked failure type OkHttp expects from DNS implementations.This keeps the DoH timeout, session-scoped disable flag, fallback log, and
UnknownHostExceptionfallback behavior added by #765 unchanged. Normal system-DNSUnknownHostExceptionfailures also continue to propagate unchanged.Validation
git diff --check./gradlew.bat --no-daemon :app:compileDebugJavaWithJavac./gradlew.bat --no-daemon :app:assembleDebugVector_API30),doh=false: manager UI launches and remains alive; no fatal crash in logcat.master: base reproducesFATAL EXCEPTION: OkHttp Dispatcher; this branch converts the same denial to a hostname-bearingUnknownHostExceptionwith no fatal crash.Reproduction boundary
I could not reproduce the exact
EPERM/SecurityExceptionon a clean API 30 emulator. Attempts included Private DNSoff,opportunistic, invalid hostname mode, Data Saver / app UID restrict-background blacklist, and a local-only no-INTERNETmanifest build. These did not reproduce the reporter's environment-specificandroid_getaddrinfo failed: EPERMpath.To verify the fix still covers the reported failure mode, I used a local-only fault-injection comparison that was not included in this PR:
origin/masterafter Fix module repository loading #765 (2a633ef0), injecting the sameSecurityException("Permission denied (missing INTERNET permission?)")before its final system DNS call withdoh=falsereproducedFATAL EXCEPTION: OkHttp DispatcherandProcess: org.lsposed.manager.tryblock kept the app alive and converted request failures to hostname-bearing messages such asjava.net.UnknownHostException: api.github.com: Permission denied (missing INTERNET permission?), with noAndroidRuntimefatal crash.doh=true, a second local-only injection forced the Fix module repository loading #765 DoH failure path before the same system denial. The existingDoH resolver unreachable, falling back to system DNS for this sessionlog still appeared, and the system denial was converted with no fatal crash.So the clean emulator cannot recreate the original device policy state, but the branch directly covers the exception class/message at the same method boundary shown in the issue stack. OnePlus 9 Pro / LE2120 was online but runs Android 14, so it was not used to claim coverage of this Android 11-specific boundary.