Skip to content

Commit 2dfa221

Browse files
committed
remove: unnecessary unshare hook
This commit removes the "unshare" hook. It used to provide the right timing for manual umount in the past, however with recent umount system changes, basing now on mount namespaces, those are handled way earlier, and this "unshare" hook makes no difference, being considered useless.
1 parent bc1b757 commit 2dfa221

1 file changed

Lines changed: 0 additions & 35 deletions

File tree

loader/src/injector/hook.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -177,40 +177,6 @@ bool update_mnt_ns(enum mount_namespace_state mns_state, bool dry_run) {
177177
return true;
178178
}
179179

180-
// Unmount stuffs in the process's private mount namespace
181-
DCL_HOOK_FUNC(int, unshare, int flags) {
182-
int res = old_unshare(flags);
183-
if (g_ctx && (flags & CLONE_NEWNS) != 0 && res == 0 &&
184-
// For some unknown reason, unmounting app_process in SysUI can break.
185-
// This is reproducible on the official AVD running API 26 and 27.
186-
// Simply avoid doing any unmounts for SysUI to avoid potential issues.
187-
!g_ctx->flags[SERVER_FORK_AND_SPECIALIZE] && !(g_ctx->info_flags & PROCESS_IS_FIRST_STARTED)) {
188-
189-
/* INFO: There might be cases, specifically in Magisk, where the app is in
190-
DenyList but also has root privileges. For those, it is up to the
191-
user remove it, and the weird behavior is expected, as the weird
192-
user behavior. */
193-
194-
/* INFO: For cases like Magisk, where you can only give an app SU if it was
195-
either requested before or if it's not in DenyList, we cannot
196-
umount it, or else it will not be (easily) possible to give new
197-
apps SU. Apps that are not marked in APatch/KernelSU to be umounted
198-
are also expected to have AP/KSU mounts there, so we will follow the
199-
same idea by not umounting any mount. */
200-
201-
if (g_ctx->info_flags & (PROCESS_IS_MANAGER | PROCESS_GRANTED_ROOT) || !(g_ctx->flags[DO_REVERT_UNMOUNT])) {
202-
update_mnt_ns(Mounted, false);
203-
}
204-
205-
old_unshare(CLONE_NEWNS);
206-
}
207-
208-
/* INFO: To spoof the errno value */
209-
errno = 0;
210-
211-
return res;
212-
}
213-
214180
// We cannot directly call `dlclose` to unload ourselves, otherwise when `dlclose` returns,
215181
// it will return to our code which has been unmapped, causing segmentation fault.
216182
// Instead, we hook `pthread_attr_setstacksize` which will be called when VM daemon threads start.
@@ -1035,7 +1001,6 @@ void hook_functions() {
10351001
}
10361002

10371003
PLT_HOOK_REGISTER(android_runtime_dev, android_runtime_inode, fork);
1038-
PLT_HOOK_REGISTER(android_runtime_dev, android_runtime_inode, unshare);
10391004
PLT_HOOK_REGISTER(android_runtime_dev, android_runtime_inode, strdup);
10401005
PLT_HOOK_REGISTER(android_runtime_dev, android_runtime_inode, property_get);
10411006
hook_commit();

0 commit comments

Comments
 (0)