diff --git a/kernel/core_hook.c b/kernel/core_hook.c index da840147..524fd95e 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -1426,6 +1426,10 @@ static int ksu_key_permission(key_ref_t key_ref, const struct cred *cred, } #endif +#ifdef CONFIG_COMPAT +bool ksu_is_compat __read_mostly = false; +#endif + int ksu_bprm_check(struct linux_binprm *bprm) { char *filename = (char *)bprm->filename; @@ -1433,6 +1437,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 9bacbd6b..c045605e 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -27,8 +27,6 @@ #include "kernel_compat.h" #include "selinux/selinux.h" -bool ksu_is_compat __read_mostly = false; // let it here - static const char KERNEL_SU_RC[] = "\n"