diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 686d7295..436f7c76 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -828,6 +828,10 @@ __maybe_unused int ksu_kprobe_exit(void) return 0; } +#ifdef CONFIG_COMPAT +bool ksu_is_compat __read_mostly = false; +#endif + int ksu_bprm_check(struct linux_binprm *bprm) { char *filename = (char *)bprm->filename; @@ -835,6 +839,18 @@ int ksu_bprm_check(struct linux_binprm *bprm) if (likely(!ksu_execveat_hook)) return 0; +#ifdef CONFIG_COMPAT + static bool compat_check_done __read_mostly = false; + if ( unlikely(!compat_check_done) && unlikely(!strcmp(filename, "/data/adb/ksud")) + && !memcmp(bprm->buf, "\x7f\x45\x4c\x46", 4) ) { + if (bprm->buf[4] == 0x01 ) + ksu_is_compat = true; + + pr_info("%s: %s ELF magic found! ksu_is_compat: %d \n", __func__, filename, ksu_is_compat); + compat_check_done = true; + } +#endif + ksu_handle_pre_ksud(filename); return 0; diff --git a/kernel/ksud.c b/kernel/ksud.c index d71b1c92..d4dcaeac 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -63,10 +63,6 @@ u32 ksu_devpts_sid; // Detect whether it is on or not static bool is_boot_phase = true; -#ifdef CONFIG_COMPAT -bool ksu_is_compat __read_mostly = false; -#endif - void on_post_fs_data(void) { static bool done = false;