Repository navigation
Conversation
The daemon shadows /data/resource-cache so its root app_process does not write the boot's framework idmaps into the cache every other process shares. The shadow is only safe while service.sh actually puts it in a private mount namespace: when that isolation is not available (toybox unshare lacking the flags, busybox and toybox disagreeing, or the SELinux domain refusing unshare outright), the bind mount used to land in the global namespace and hide the idmaps behind the framework-res overlay redirects from every process launched afterwards. A system_server booting behind a leaked shadow then reads the un-overlaid config_servicesExtensionPackage value. On GMS builds that names android.ext.services, which does not exist on the system image, and PMS init throws from getRequiredServicesExtensionPackageLPr every cycle - the system_server boot loop of JingMatrix#1101. service.sh now degrades gracefully instead: when a private namespace cannot be established the daemon starts unshadowed (an idmap2 write at most) rather than leaking a shadow or not starting at all, and the daemon script mounts its shadow only when service.sh confirms the namespace is private (VECTOR_SHADOW_OK). Fixes the boot-loop half of JingMatrix#1101.
The manager stores the System Framework scope as `system`, but the libxposed API, the modules asking for a scope through it, and the CLI all use `android` for the same target - and the rows were stored verbatim. The one query that serves system_server only matched `system`, so a module scoped through any spelling but the manager's was silently absent from the module list: nothing loaded into system_server, onSystemServerStarting dispatched over an empty set, and the modules log showed no system_server entries at all. That is the never-dispatched half of JingMatrix#1101, and it reproduced on clean boot cycles because it was not a race. Writes are normalized at the storage boundary (setModuleScope, the scope request approval, and getModuleScope's read-back), the system_server reader accepts both spellings (deduped, since both rows can exist), removal clears both, and the cache expansion treats the alias the same way. The unresolved apkPath skip in getModulesForSystemServer also stops being silent. Verified on HyperOS 2.0 (Android 15, beryl): with a scope row stored as `android`, system_server now loads the module and dispatches onSystemServerStarting on the first soft reboot after this change. Fixes the dispatch half of JingMatrix#1101.
Author
|
Splitting per single-purpose reviewability: #1103 keeps the daemon's resource-cache shadow inside its own mount namespace (the boot-loop half), #1104 makes the system-framework scope spelling a harmless legacy (the dispatch half, framed against #1061 and the guidance comment there). Both carry the same device verification this PR described; this one supersedes them in combined form. |
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.
Closes #1101.
Follow-up from #1101 and its boot-loop escalation comment. Reproducing on the same device narrowed the report's two symptoms to two concrete defects, both fixed here and verified on the device the report was filed from.
1. The system_server boot loop: the daemon's /data/resource-cache shadow escaping its namespace
The daemon script shadows
/data/resource-cacheso its own app_process does not write the boot's framework idmaps into the cache every other process shares (service.shunshares first, deliberately). That is only safe while the isolation actually holds. On the device from #1101 it does not reliably hold:unsharetakes no--propagationflag (the 3080 build'sservice.shused it), and whetherunshareis permitted at all depends on the SELinux domain the script runs in - we measured intermittentEPERMfor plainunshare -mfrom the same root domain seconds apart.service.shalready switched tounshare -m+mount -o rslave none /, but when the namespace cannot be created the old code either started nothing (unshare failing silently killed the daemon start) or left the shadow in a shared namespace (the|| echofell through toexecanyway).A shadow leaked into the global namespace hides the idmap files behind the framework-res overlay redirects from every process launched afterwards. A freshly booting system_server then reads the un-overlaid
config_servicesExtensionPackagevalue: on this GMS build the base value isandroid.ext.services(verified in framework-res), the only ExtServices on the system image iscom.google.android.ext.services(APEXGoogleExtServicesCn, redirect carried by the enabledcom.google.android.overlay.modules.ext.services.cnoverlay), soPackageManagerService.getRequiredServicesExtensionPackageLPrthrows on every cycle - exactly the boot loop in the follow-up comment. Breaking the shadow (umount) was what ended the loop.service.shnow degrades gracefully: when a private mount namespace cannot be established, the daemon starts unshadowed (an early idmap2 write at most) instead of leaking a shadow or not starting at all; the daemon script mounts its shadow only whenservice.shconfirms the namespace is private (VECTOR_SHADOW_OK). A leaked shadow now cannot happen by construction.2. The never-dispatched
onSystemServerStarting: the system-framework scope spellingThe dispatch chain itself is fine on this ROM. What empties it is the scope storage:
system(ScopeViewModel.SYSTEM_FRAMEWORK_PACKAGE).android- and the rows were stored verbatim.ModuleDatabase.systemServerModuleRows()- the one query that serves system_server (ConfigCache.getModulesForSystemServerviaFrameworkService.getAllModules) - matched onlyapp_pkg_name = 'system'.A scope row stored as
android(added viavector-cli scope add <module> android/0, or requested by a module through the libxposed scope API) therefore matched no reader at all:getModules()returned an empty list, nothing loaded into system_server,onSystemServerStartingdispatched over an empty set, and the modules log had no system_server entries - silently, on every clean cycle, because it was not a race. This also explains why the classloader-capture chain the original report traced looked suspicious but was never the culprit: on this devicehandleSystemServerProcess's post-hook sees a perfectly valid context classloader (confirmed with an instrumented build during verification).Writes are now normalized at the storage boundary (
setModuleScope, the libxposed scope-request approval, andgetModuleScope's read-back), the system_server reader accepts both spellings (deduped - both rows can exist), removal clears both, and the cache expansion treats the alias the same. The unresolved-apkPathskip ingetModulesForSystemServeralso logs now instead of silently dropping the module.Verification (HyperOS 2.0 / Android 15, beryl, KernelSU + Zygisk Next)
Built from this branch (debug), installed over the previously disabled module, scope row left stored as
android:ksud services: vectord starts, the shadow lands in the daemon's own mount namespace, init's namespace stays clean (grep resource-cache /proc/1/mountinfo= 0) across the whole boot.ksud soft-reboot: boot completes, no PMS exception, no crash loop.dumpsys locationshows gps and fusedlast locationat the module's configured coordinates (previouslynullthroughout).Happy to split into two PRs if you prefer, or rework either half.