kernel: Add CMD_HOOK_TYPE handling to core_hook.c to support state lookups for manual hooks

Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: rifsxd <rifat.44.azad.rifs@gmail.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-06-13 15:42:11 +08:00
parent a873411a07
commit 36cca65af3
2 changed files with 24 additions and 0 deletions

View File

@@ -529,6 +529,29 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
return 0;
}
if (arg2 == CMD_HOOK_TYPE) {
const char *hook_type;
#ifdef CONFIG_KSU_MANUAL_HOOK
hook_type = "Manual";
#elif defined(CONFIG_KSU_KPROBES_HOOK)
hook_type = "Kprobes";
#else
hook_type = "Unknown";
#endif
size_t len = strlen(hook_type) + 1;
if (copy_to_user((void __user *)arg3, hook_type, len)) {
pr_err("hook_type: copy_to_user failed\n");
return 0;
}
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
pr_err("hook_type: prctl reply error\n");
}
return 0;
}
#ifdef CONFIG_KSU_SUSFS
if (current_uid_val == 0) {
#ifdef CONFIG_KSU_SUSFS_SUS_PATH

View File

@@ -24,6 +24,7 @@
#define CMD_IS_SU_ENABLED 14
#define CMD_ENABLE_SU 15
#define CMD_ENABLE_KPM 100
#define CMD_HOOK_TYPE 101
#define EVENT_POST_FS_DATA 1
#define EVENT_BOOT_COMPLETED 2