From cb8472c967605b2c9ff26419b66706bea39d9f86 Mon Sep 17 00:00:00 2001 From: sekaiacg Date: Wed, 1 May 2024 09:34:21 +0800 Subject: [PATCH] kpm: Sync KernelPatch header files to 0.10.7 Signed-off-by: sekaiacg --- kernel/include/preset.h | 9 ++++++ kernel/linux/arch/arm64/include/asm/ptrace.h | 2 +- kernel/patch/include/syscall.h | 31 ++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/kernel/include/preset.h b/kernel/include/preset.h index 1970d33..af5921f 100644 --- a/kernel/include/preset.h +++ b/kernel/include/preset.h @@ -117,6 +117,15 @@ struct patch_symbol uint64_t __cfi_slowpath; uint64_t copy_process; uint64_t cgroup_post_fork; + uint64_t do_execveat_common; + uint64_t __do_execve_file; + uint64_t do_execve_common; + uint64_t do_faccessat; + uint64_t sys_faccessat; + uint64_t sys_faccessat2; + uint64_t sys_newfstatat; + uint64_t vfs_statx; + uint64_t vfs_fstatat; uint64_t avc_denied; uint64_t slow_avc_audit; uint64_t input_handle_event; diff --git a/kernel/linux/arch/arm64/include/asm/ptrace.h b/kernel/linux/arch/arm64/include/asm/ptrace.h index 63caef6..fc98797 100644 --- a/kernel/linux/arch/arm64/include/asm/ptrace.h +++ b/kernel/linux/arch/arm64/include/asm/ptrace.h @@ -276,7 +276,7 @@ static inline void forget_syscall(struct pt_regs *regs) static inline unsigned long user_stack_pointer(struct pt_regs *regs) { - // if (compat_user_mode(regs)) return regs->compat_sp; + if (compat_user_mode(regs)) return regs->compat_sp; return regs->sp; } diff --git a/kernel/patch/include/syscall.h b/kernel/patch/include/syscall.h index c49223e..af024ea 100644 --- a/kernel/patch/include/syscall.h +++ b/kernel/patch/include/syscall.h @@ -13,6 +13,7 @@ #include extern uintptr_t *sys_call_table; +extern uintptr_t *compat_sys_call_table; extern int has_syscall_wrapper; const char __user *get_user_arg_ptr(void *a0, void *a1, int nr); @@ -68,6 +69,21 @@ static inline void fp_unhook_syscall(int nr, void *before, void *after) fp_hook_unwrap(fp_addr, before, after); } +static inline hook_err_t fp_hook_compat_syscalln(int nr, int narg, void *before, void *after, void *udata) +{ + if (!compat_sys_call_table) return HOOK_BAD_ADDRESS; + uintptr_t fp_addr = (uintptr_t)(compat_sys_call_table + nr); + if (has_syscall_wrapper) narg = 1; + return fp_hook_wrap(fp_addr, narg, before, after, udata); +} + +static inline void fp_unhook_compat_syscall(int nr, void *before, void *after) +{ + if (!compat_sys_call_table) return; + uintptr_t fp_addr = (uintptr_t)(compat_sys_call_table + nr); + fp_hook_unwrap(fp_addr, before, after); +} + /* xxx.cfi_jt example: hint #0x22 @@ -86,6 +102,21 @@ static inline void inline_unhook_syscall(int nr, void *before, void *after) hook_unwrap((void *)fp, before, after); } +static inline hook_err_t inline_hook_compat_syscalln(int nr, int narg, void *before, void *after, void *udata) +{ + if (!compat_sys_call_table) return HOOK_BAD_ADDRESS; + uintptr_t fp = compat_sys_call_table[nr]; + if (has_syscall_wrapper) narg = 1; + return hook_wrap((void *)fp, narg, before, after, udata); +} + +static inline void inline_unhook_compat_syscall(int nr, void *before, void *after) +{ + if (!compat_sys_call_table) return; + uintptr_t fp = compat_sys_call_table[nr]; + hook_unwrap((void *)fp, before, after); +} + int syscall_init(); #endif \ No newline at end of file