kernel: Rewrite the kernel source code (#554)
* clean unused header * on_module_mounted in ksud.c * refact: use app_profile * unified hook manager * add zygote to hook target * move reboot hook to supercall.c * refactor: kernel_umount setuid_hook * update mark rules, add init mark tracker * remove reboot from check_syscall_fastpath * update setuid_hook, remove uneeded sucompat enable * log freely * kernel: Migrate kprobe hook configuration items * kernel: fix build * cli: add ksud debug mark * Fix rustfmt warning --------- Co-authored-by: Ylarod <me@ylarod.cn> Co-authored-by: Wang Han <416810799@qq.com> Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
40
kernel/syscall_hook_manager.h
Normal file
40
kernel/syscall_hook_manager.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef __KSU_H_HOOK_MANAGER
|
||||
#define __KSU_H_HOOK_MANAGER
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/thread_info.h>
|
||||
|
||||
// Hook manager initialization and cleanup
|
||||
void ksu_syscall_hook_manager_init(void);
|
||||
void ksu_syscall_hook_manager_exit(void);
|
||||
|
||||
// Process marking for tracepoint
|
||||
void ksu_mark_all_process(void);
|
||||
void ksu_unmark_all_process(void);
|
||||
void ksu_mark_running_process(void);
|
||||
|
||||
// Per-task mark operations
|
||||
int ksu_get_task_mark(pid_t pid);
|
||||
int ksu_set_task_mark(pid_t pid, bool mark);
|
||||
|
||||
|
||||
static inline void ksu_set_task_tracepoint_flag(struct task_struct *t)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||
set_task_syscall_work(t, SYSCALL_TRACEPOINT);
|
||||
#else
|
||||
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void ksu_clear_task_tracepoint_flag(struct task_struct *t)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||
clear_task_syscall_work(t, SYSCALL_TRACEPOINT);
|
||||
#else
|
||||
clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user