From 6807e1d88f2983b30342bd122bd6c248ee175af5 Mon Sep 17 00:00:00 2001 From: Kadir <104317272+KadirJeager@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:17:46 +0300 Subject: [PATCH] Hook processes that run in a Private Compute Core sandbox Android 17 runs some app processes in a Private Compute Core sandbox: the process is the app's own (its package, process name and data directory) but runs under a uid of its own, the app's uid moved into the PCC range 30000-39999 (Process.FIRST_PCC_UID, getAppUidForPrivateComputeCoreUid). Android System Intelligence runs its main process this way, shown as u0a202p202 next to the app's u0a202. Scopes are recorded under the app's uid, so the lookup for such a process found nothing: zygisk asked the daemon, the daemon answered that nothing had it in scope, and only the app's ordinary processes (:migration) were hooked. The lookup now uses the uid of the app the process belongs to. Co-Authored-By: Claude Opus 5.5 --- .../matrix/vector/daemon/data/ConfigCache.kt | 4 +-- .../vector/daemon/system/SystemExtensions.kt | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/daemon/src/main/kotlin/org/matrix/vector/daemon/data/ConfigCache.kt b/daemon/src/main/kotlin/org/matrix/vector/daemon/data/ConfigCache.kt index b79aa11817..95474c6cff 100644 --- a/daemon/src/main/kotlin/org/matrix/vector/daemon/data/ConfigCache.kt +++ b/daemon/src/main/kotlin/org/matrix/vector/daemon/data/ConfigCache.kt @@ -462,7 +462,7 @@ object ConfigCache { Log.w(TAG, "Skip unexpected module queries for $processName") return emptyList() } - return state.scopes[ProcessScope(processName, uid)] ?: emptyList() + return state.scopes[ProcessScope(processName, appUidOf(uid))] ?: emptyList() } fun getModuleByUid(uid: Int): LoadedModule? = @@ -603,7 +603,7 @@ object ConfigCache { fun shouldSkipProcess(scope: ProcessScope): Boolean { ensureCacheReady() - return !state.scopes.containsKey(scope) + return !state.scopes.containsKey(scope.copy(uid = appUidOf(scope.uid))) } fun getPrefsPath(packageName: String, uid: Int): String { diff --git a/daemon/src/main/kotlin/org/matrix/vector/daemon/system/SystemExtensions.kt b/daemon/src/main/kotlin/org/matrix/vector/daemon/system/SystemExtensions.kt index 65020bd383..c565c1238f 100644 --- a/daemon/src/main/kotlin/org/matrix/vector/daemon/system/SystemExtensions.kt +++ b/daemon/src/main/kotlin/org/matrix/vector/daemon/system/SystemExtensions.kt @@ -29,6 +29,31 @@ const val PER_USER_RANGE = 100000 * by [PER_USER_RANGE] is only a user test for uids on this side of the line. */ const val FIRST_APPLICATION_UID = 10000 + +/** + * The Private Compute Core uid range of each user, as `android.os.Process.FIRST_PCC_UID` and + * `LAST_PCC_UID` (Android 17). + * + * Android 17 can run an app's processes in a Private Compute Core sandbox. Such a process belongs + * to the app — its package, its process names, its data directory — but runs under a uid of its + * own, the app's uid moved by `FIRST_PCC_UID - FIRST_APPLICATION_UID` into this range (dumpsys + * shows it as `u0a202p202`). Android System Intelligence runs its main process this way. + */ +const val FIRST_PCC_UID = 30000 +const val LAST_PCC_UID = 39999 + +/** + * The uid of the app a process belongs to: [uid] itself, or for a Private Compute Core process the + * app uid it was derived from, as `android.os.Process.getAppUidForPrivateComputeCoreUid`. + * + * Scopes are recorded under the app's uid, so a process is looked up by this one. + */ +fun appUidOf(uid: Int): Int { + val appId = uid % PER_USER_RANGE + return if (appId in FIRST_PCC_UID..LAST_PCC_UID) uid - (FIRST_PCC_UID - FIRST_APPLICATION_UID) + else uid +} + const val MATCH_ANY_USER = 0x00400000 // PackageManager.MATCH_ANY_USER const val MATCH_ALL_FLAGS = PackageManager.MATCH_DISABLED_COMPONENTS or