fix: removal of all PLT hooks unconditionally

This commit fixes the issue where due to a confusion, ReZygisk was coded so that it would remove all PLT hooks, even if they were meant to be kept. This has been fixed appropriately in LSPlt side, allowing to revert back to how it was before.
This commit is contained in:
ThePedroo
2025-06-06 03:00:05 -03:00
parent c023da0fd6
commit ec705fb260
2 changed files with 17 additions and 19 deletions

View File

@@ -31,6 +31,7 @@
using namespace std; using namespace std;
static void hook_unloader(); static void hook_unloader();
static void unhook_functions();
namespace { namespace {
@@ -219,14 +220,8 @@ DCL_HOOK_FUNC(int, pthread_attr_setstacksize, void *target, size_t size) {
if (gettid() != getpid()) if (gettid() != getpid())
return res; return res;
delete plt_hook_list;
if (should_unmap_zygisk) { if (should_unmap_zygisk) {
if (!lsplt::InvalidateBackup()) { unhook_functions();
LOGE("Failed to invalidate backup for plt_hook");
should_unmap_zygisk = false;
}
cached_map_infos.clear(); cached_map_infos.clear();
if (should_unmap_zygisk) { if (should_unmap_zygisk) {
@@ -237,17 +232,6 @@ DCL_HOOK_FUNC(int, pthread_attr_setstacksize, void *target, size_t size) {
[[clang::musttail]] return munmap(start_addr, block_size); [[clang::musttail]] return munmap(start_addr, block_size);
} }
} else {
for (const auto &[dev, inode, sym, old_func] : *plt_hook_list) {
if (!lsplt::RegisterHook(dev, inode, sym, *old_func, nullptr)) {
LOGE("Failed to register plt_hook [%s]", sym);
}
}
if (!lsplt::CommitHook(cached_map_infos)) {
LOGE("Failed to restore plt_hook");
should_unmap_zygisk = false;
}
} }
return res; return res;
@@ -966,3 +950,17 @@ static void hook_unloader() {
PLT_HOOK_REGISTER(art_dev, art_inode, pthread_attr_setstacksize); PLT_HOOK_REGISTER(art_dev, art_inode, pthread_attr_setstacksize);
hook_commit(); hook_commit();
} }
static void unhook_functions() {
// Unhook plt_hook
for (const auto &[dev, inode, sym, old_func] : *plt_hook_list) {
if (!lsplt::RegisterHook(dev, inode, sym, *old_func, nullptr)) {
LOGE("Failed to register plt_hook [%s]", sym);
}
}
delete plt_hook_list;
if (!hook_commit()) {
LOGE("Failed to restore plt_hook");
should_unmap_zygisk = false;
}
}