Fixes only hook in LKM mode __NR_newfstatat ,__NR_faccessat ,__NR_execve system calls

This commit is contained in:
ShirkNeko
2025-11-09 12:16:23 +08:00
parent 6530d06710
commit 049956aaa9
2 changed files with 6 additions and 3 deletions

View File

@@ -130,6 +130,7 @@ ccflags-y += -DKSU_MANUAL_HOOK
$(info -- SukiSU: KSU_MANUAL_HOOK) $(info -- SukiSU: KSU_MANUAL_HOOK)
else else
ccflags-y += -DKSU_HAVE_SYSCALL_TRACEPOINTS_HOOK ccflags-y += -DKSU_HAVE_SYSCALL_TRACEPOINTS_HOOK
ccflags-y += -DKSU_LKM_MODE
ccflags-y += -DKSU_KPROBES_HOOK ccflags-y += -DKSU_KPROBES_HOOK
$(info -- SukiSU: KSU_TRACEPOINT_HOOK) $(info -- SukiSU: KSU_TRACEPOINT_HOOK)
endif endif

View File

@@ -315,11 +315,12 @@ static inline void ksu_handle_task_alloc(struct pt_regs *regs)
#endif #endif
} }
#ifdef KSU_HAVE_SYSCALL_TRACEPOINTS_HOOK #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
// Generic sys_enter handler that dispatches to specific handlers // Generic sys_enter handler that dispatches to specific handlers
static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id) static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id)
{ {
if (unlikely(check_syscall_fastpath(id))) { if (unlikely(check_syscall_fastpath(id))) {
#ifdef KSU_LKM_MODE
if (ksu_su_compat_enabled) { if (ksu_su_compat_enabled) {
// Handle newfstatat // Handle newfstatat
if (id == __NR_newfstatat) { if (id == __NR_newfstatat) {
@@ -355,6 +356,7 @@ static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id)
return; return;
} }
} }
#endif
// Handle setresuid // Handle setresuid
if (id == __NR_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); syscall_unregfunc_rp = init_kretprobe("syscall_unregfunc", syscall_unregfunc_handler);
#endif #endif
#ifdef KSU_HAVE_SYSCALL_TRACEPOINTS_HOOK #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
ret = register_trace_sys_enter(ksu_sys_enter_handler, NULL); ret = register_trace_sys_enter(ksu_sys_enter_handler, NULL);
#ifndef CONFIG_KRETPROBES #ifndef CONFIG_KRETPROBES
unmark_all_process(); unmark_all_process();
@@ -414,7 +416,7 @@ void ksu_syscall_hook_manager_init(void)
void ksu_syscall_hook_manager_exit(void) void ksu_syscall_hook_manager_exit(void)
{ {
pr_info("hook_manager: ksu_hook_manager_exit called\n"); 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); unregister_trace_sys_enter(ksu_sys_enter_handler, NULL);
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
pr_info("hook_manager: sys_enter tracepoint unregistered\n"); pr_info("hook_manager: sys_enter tracepoint unregistered\n");