Skip to content

Commit

Permalink
kpm: Sync KernelPatch header files to 0.10.7
Browse files Browse the repository at this point in the history
Signed-off-by: sekaiacg <sekaiacg@gmail.com>
  • Loading branch information
sekaiacg committed May 1, 2024
1 parent 9aff7be commit cb8472c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
9 changes: 9 additions & 0 deletions kernel/include/preset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion kernel/linux/arch/arm64/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
31 changes: 31 additions & 0 deletions kernel/patch/include/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <uapi/asm-generic/unistd.h>

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);
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit cb8472c

Please sign in to comment.