From 049956aaa97d9e0729f2f0c20d6159103d4243c9 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Sun, 9 Nov 2025 12:16:23 +0800 Subject: [PATCH] Fixes only hook in LKM mode `__NR_newfstatat` ,`__NR_faccessat` ,`__NR_execve` system calls --- kernel/Makefile | 1 + kernel/syscall_hook_manager.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index b9ae8b3e..5da3b089 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -130,6 +130,7 @@ ccflags-y += -DKSU_MANUAL_HOOK $(info -- SukiSU: KSU_MANUAL_HOOK) else ccflags-y += -DKSU_HAVE_SYSCALL_TRACEPOINTS_HOOK +ccflags-y += -DKSU_LKM_MODE ccflags-y += -DKSU_KPROBES_HOOK $(info -- SukiSU: KSU_TRACEPOINT_HOOK) endif diff --git a/kernel/syscall_hook_manager.c b/kernel/syscall_hook_manager.c index a29bc2c3..979bd44e 100644 --- a/kernel/syscall_hook_manager.c +++ b/kernel/syscall_hook_manager.c @@ -315,11 +315,12 @@ static inline void ksu_handle_task_alloc(struct pt_regs *regs) #endif } -#ifdef KSU_HAVE_SYSCALL_TRACEPOINTS_HOOK +#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS // Generic sys_enter handler that dispatches to specific handlers static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id) { if (unlikely(check_syscall_fastpath(id))) { +#ifdef KSU_LKM_MODE if (ksu_su_compat_enabled) { // Handle newfstatat if (id == __NR_newfstatat) { @@ -355,6 +356,7 @@ static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id) return; } } +#endif // Handle setresuid if (id == __NR_setresuid) { @@ -394,7 +396,7 @@ void ksu_syscall_hook_manager_init(void) syscall_unregfunc_rp = init_kretprobe("syscall_unregfunc", syscall_unregfunc_handler); #endif -#ifdef KSU_HAVE_SYSCALL_TRACEPOINTS_HOOK +#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS ret = register_trace_sys_enter(ksu_sys_enter_handler, NULL); #ifndef CONFIG_KRETPROBES unmark_all_process(); @@ -414,7 +416,7 @@ void ksu_syscall_hook_manager_init(void) void ksu_syscall_hook_manager_exit(void) { pr_info("hook_manager: ksu_hook_manager_exit called\n"); -#ifdef KSU_HAVE_SYSCALL_TRACEPOINTS_HOOK +#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS unregister_trace_sys_enter(ksu_sys_enter_handler, NULL); tracepoint_synchronize_unregister(); pr_info("hook_manager: sys_enter tracepoint unregistered\n");