Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 12 hook 后 cfi_check 崩溃显著增加 #98

Open
onvejon opened this issue May 29, 2024 · 1 comment
Open

Android 12 hook 后 cfi_check 崩溃显著增加 #98

onvejon opened this issue May 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@onvejon
Copy link

onvejon commented May 29, 2024

bytehook Version

1.0.10

Android OS Version

12

Android ABIs

armeabi-v7a

Device Manufacturers and Models

定制安卓设备

Describe the Bug

image
目前遇到的情况是,启用hook后,极易出现 cfi_check 崩溃,关闭后则几乎不会出现 cfi_check 崩溃。希望获得大佬的指定和帮助。

hook代码如下,对libc的socket接口进行了hook。其他一切配置都是按照例子里面的调用方法。
有一点疑惑的点:调用hook的时机不是在 Application.onCreate. 而是在App启动后的一段时间才hook的,和例子有些不同,不知道这样调用会有什么影响。

static bool allow_filter(const char *caller_path_name, void *arg) {
    (void)arg;

    if (NULL != strstr(caller_path_name, "libc.so")) return false;
    if (NULL != strstr(caller_path_name, "libbase.so")) return false;
    if (NULL != strstr(caller_path_name, "liblog.so")) return false;
    if (NULL != strstr(caller_path_name, "libunwindstack.so")) return false;
    if (NULL != strstr(caller_path_name, "libutils.so")) return false;
    // ......

    return true;
}

if (!sock_sendto_stub) {
        sock_sendto_stub = bytehook_hook_partial(allow_filter, NULL, "libc.so", "sendto" , sock_sendto_proxy_auto, sock_sendto_hooked_callback, NULL);
    }
    if (!sock_recvfrom_stub) {
        sock_recvfrom_stub = bytehook_hook_partial(allow_filter, NULL, "libc.so", "recvfrom" , sock_recvfrom_proxy_auto, sock_recvfrom_hooked_callback, NULL);
    }
@onvejon onvejon added the bug Something isn't working label May 29, 2024
@caikelun
Copy link
Member

感谢反馈这个问题。

这个问题的原因应该是目前 bytehook 对 CFI 的处理只针对了 64 位设备。根据我们之前的数据观察,可能是因为开启 CFI 需要消耗比较多的内存,所以在线上的移动设备中,只发现厂商在部分 64 位设备上会开启 CFI。

bytehook 对 CFI 的处理主要在 bh_hook_manager.cbh_elf.c 中,加了 #ifdef __LP64__ 宏,你可以把对应位置的宏去掉试试。或者也可以等即将发布的新版本,我会在新版中修改这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants