Fix correct hook type acquisition

This commit is contained in:
ShirkNeko
2025-08-14 23:18:21 +08:00
parent e96194c7ff
commit dbc662486b
3 changed files with 25 additions and 21 deletions

View File

@@ -522,25 +522,6 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
return 0;
}
// Checking hook usage
if (arg2 == CMD_HOOK_TYPE) {
const char *hook_type;
#if defined(CONFIG_KSU_KPROBES_HOOK)
hook_type = "Kprobes";
#elif defined(CONFIG_KSU_TRACEPOINT_HOOK)
hook_type = "Tracepoint";
#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;
}
}
#ifdef CONFIG_KPM
// ADD: 添加KPM模块控制
if(sukisu_is_kpm_control_code(arg2)) {
@@ -561,6 +542,29 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
return 0;
}
// Checking hook usage
if (arg2 == CMD_HOOK_TYPE) {
const char *hook_type;
#ifdef CONFIG_KSU_TRACEPOINT_HOOK
hook_type = "Tracepoint";
#else
hook_type = "Kprobes";
#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;
}
// all other cmds are for 'root manager'
if (!from_manager) {
return 0;

View File

@@ -621,5 +621,5 @@
<string name="module_signature_invalid">未知发布者</string>
<string name="module_signature_invalid_message">未经签名的模块可能不完整。为了对设备进行保护,已阻止安装此模块。</string>
<string name="module_signature_verification_failed">未经签名的模块可能不完整。你想安装来自未知发布者的模块吗?</string>
<string name="home_hook_type">钩子类型: %s</string>
<string name="home_hook_type">钩子类型</string>
</resources>

View File

@@ -629,5 +629,5 @@ Important Note:\n
<string name="module_signature_invalid">Unknown publisher</string>
<string name="module_signature_invalid_message">Unsigned modules may be incomplete. To protect your device, installation of this module has been blocked.</string>
<string name="module_signature_verification_failed">Unsigned modules may be incomplete. Do you want to allow the following module from an unknown publisher to install in this device?</string>
<string name="home_hook_type">Hook type: %s</string>
<string name="home_hook_type">Hook type</string>
</resources>