* refactor: replace throne tracker with ksud token
* use snprintf
* refactor: new supercall impl
- Import the sukisu command
* disable seccomp for supercall users
* kernel: fmt clear
* kernel: Enable macro protection for sulog
- Only enabled on kernel versions greater than 5.10.245
* kernel: Refactor kprobe hooks and implement LSM hooks for improved security handling
* debug mode
* kernel: Add functionality to generate and validate authentication tokens for cmd_su
* kernel: Simplified manual SU command processing for code
* kernel: replace renameat hook with fsnotify
* Revert "refactor: replace throne tracker with ksud token"
This reverts commit aa2cbbf.
* kernel: fix compile
* kernel: fix compile below 6.0
* Fix compile err; Add become_manager
* kernel: install fd for manager automaticlly
- extend to import the corresponding command
* manager: new supercall impl
* temp changes for ksud
* ksud: fix compile
* fix wrong opcode
* kernel: fix compile
* kernel: Fixed hook type and KPM status retrieval errors
* kernel: Fixed potential null pointer issue with current->mm in kernel version 5.10
When calling get_full_comm() within system call hooks, current->mm may be null (prctl). A fallback mechanism for current->comm must be added beforehand to prevent null pointer dereferences when accessing mm->arg_start/arg_end.
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
* ksud: fix cargo check
* manager: Fixed an issue where the KSUD release and user-mode scanning switch failed to function correctly.
- kernel: fix spin lock mutual
kernel: Fixed potential null pointer issue with current->mm in kernel version 5.10
When calling get_full_comm() within system call hooks, current->mm may be null (prctl). A fallback mechanism for current->comm must be added beforehand to prevent null pointer dereferences when accessing mm->arg_start/arg_end.
kernel: try introduce like susfs's method to fix prctl delay
* seccomp: allow reboot
* use u32
* update clang-format
* 4 spaces save the world
* ksud: Fix build on macOS
* manager: bump minimal supported kernel.
- When get_hook_type is empty, display “Unknown”.
* Fix ksud build (#2841)
* try fix ksud
* fix for macos
* remove any
* Fix ksud build, take 3
* try fix allowlist
* bring lsm hook back
* fix: a lot again
* Fix ksud build, take 4 (#2846)
Remove init_driver_fd function for non-linux/android targets
* manager: Return to the native method via KSUd installation
* Merge with susfs-mian format
---------
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: weishu <twsxtd@gmail.com>
Co-authored-by: AlexLiuDev233 <wzylin11@outlook.com>
Co-authored-by: Wang Han <416810799@qq.com>
118 lines
4.0 KiB
C
118 lines
4.0 KiB
C
#ifndef __KSU_H_ARCH
|
|
#define __KSU_H_ARCH
|
|
|
|
#include <linux/version.h>
|
|
|
|
#if defined(__aarch64__)
|
|
|
|
#define __PT_PARM1_REG regs[0]
|
|
#define __PT_PARM2_REG regs[1]
|
|
#define __PT_PARM3_REG regs[2]
|
|
#define __PT_SYSCALL_PARM4_REG regs[3]
|
|
#define __PT_CCALL_PARM4_REG regs[3]
|
|
#define __PT_PARM5_REG regs[4]
|
|
#define __PT_PARM6_REG regs[5]
|
|
#define __PT_RET_REG regs[30]
|
|
#define __PT_FP_REG regs[29] /* Works only with CONFIG_FRAME_POINTER */
|
|
#define __PT_RC_REG regs[0]
|
|
#define __PT_SP_REG sp
|
|
#define __PT_IP_REG pc
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
|
|
#define PRCTL_SYMBOL "__arm64_sys_prctl"
|
|
#define REBOOT_SYMBOL "__arm64_sys_reboot"
|
|
#define SYS_READ_SYMBOL "__arm64_sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "__arm64_sys_newfstatat"
|
|
#define SYS_FSTATAT64_SYMBOL "__arm64_sys_fstatat64"
|
|
#define SYS_FACCESSAT_SYMBOL "__arm64_sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "__arm64_sys_execve"
|
|
#define SYS_EXECVE_COMPAT_SYMBOL "__arm64_compat_sys_execve"
|
|
#else
|
|
#define PRCTL_SYMBOL "sys_prctl"
|
|
#define REBOOT_SYMBOL "sys_reboot"
|
|
#define SYS_READ_SYMBOL "sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
|
|
#define SYS_FSTATAT64_SYMBOL "sys_fstatat64"
|
|
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "sys_execve"
|
|
#define SYS_EXECVE_COMPAT_SYMBOL "compat_sys_execve"
|
|
#endif
|
|
/*LSM HOOK*/
|
|
#define SECURITY_TASK_FIX_SETUID_SYMBOL "security_task_fix_setuid"
|
|
#define INODE_PERMISSION_SYMBOL "security_inode_permission"
|
|
#define BPRM_CHECK_SECURITY_SYMBOL "security_bprm_check"
|
|
#define TASK_ALLOC_SYMBOL "security_task_alloc"
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define __PT_PARM1_REG di
|
|
#define __PT_PARM2_REG si
|
|
#define __PT_PARM3_REG dx
|
|
/* syscall uses r10 for PARM4 */
|
|
#define __PT_SYSCALL_PARM4_REG r10
|
|
#define __PT_CCALL_PARM4_REG cx
|
|
#define __PT_PARM5_REG r8
|
|
#define __PT_PARM6_REG r9
|
|
#define __PT_RET_REG sp
|
|
#define __PT_FP_REG bp
|
|
#define __PT_RC_REG ax
|
|
#define __PT_SP_REG sp
|
|
#define __PT_IP_REG ip
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
|
|
#define PRCTL_SYMBOL "__x64_sys_prctl"
|
|
#define REBOOT_SYMBOL "__x64_sys_reboot"
|
|
#define SYS_READ_SYMBOL "__x64_sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "__x64_sys_newfstatat"
|
|
#define SYS_FSTATAT64_SYMBOL "__x64_sys_fstatat64"
|
|
#define SYS_FACCESSAT_SYMBOL "__x64_sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "__x64_sys_execve"
|
|
#define SYS_EXECVE_COMPAT_SYMBOL "__x64_compat_sys_execve"
|
|
#else
|
|
#define PRCTL_SYMBOL "sys_prctl"
|
|
#define REBOOT_SYMBOL "sys_reboot"
|
|
#define SYS_READ_SYMBOL "sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
|
|
#define SYS_FSTATAT64_SYMBOL "sys_fstatat64"
|
|
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "sys_execve"
|
|
#define SYS_EXECVE_COMPAT_SYMBOL "compat_sys_execve"
|
|
#endif
|
|
/*LSM HOOK*/
|
|
#define SECURITY_TASK_FIX_SETUID_SYMBOL "security_task_fix_setuid"
|
|
#define PRCTL_SYMBOL "__arm64_sys_prctl"
|
|
#define INODE_PERMISSION_SYMBOL "security_inode_permission"
|
|
#define BPRM_CHECK_SECURITY_SYMBOL "security_bprm_check"
|
|
#define TASK_ALLOC_SYMBOL "security_task_alloc"
|
|
|
|
#else
|
|
#ifdef CONFIG_KSU_KPROBES_HOOK
|
|
#error "Unsupported arch"
|
|
#endif
|
|
#endif
|
|
|
|
/* allow some architecutres to override `struct pt_regs` */
|
|
#ifndef __PT_REGS_CAST
|
|
#define __PT_REGS_CAST(x) (x)
|
|
#endif
|
|
|
|
#define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
|
|
#define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG)
|
|
#define PT_REGS_PARM3(x) (__PT_REGS_CAST(x)->__PT_PARM3_REG)
|
|
#define PT_REGS_SYSCALL_PARM4(x) (__PT_REGS_CAST(x)->__PT_SYSCALL_PARM4_REG)
|
|
#define PT_REGS_CCALL_PARM4(x) (__PT_REGS_CAST(x)->__PT_CCALL_PARM4_REG)
|
|
#define PT_REGS_PARM5(x) (__PT_REGS_CAST(x)->__PT_PARM5_REG)
|
|
#define PT_REGS_PARM6(x) (__PT_REGS_CAST(x)->__PT_PARM6_REG)
|
|
#define PT_REGS_RET(x) (__PT_REGS_CAST(x)->__PT_RET_REG)
|
|
#define PT_REGS_FP(x) (__PT_REGS_CAST(x)->__PT_FP_REG)
|
|
#define PT_REGS_RC(x) (__PT_REGS_CAST(x)->__PT_RC_REG)
|
|
#define PT_REGS_SP(x) (__PT_REGS_CAST(x)->__PT_SP_REG)
|
|
#define PT_REGS_IP(x) (__PT_REGS_CAST(x)->__PT_IP_REG)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
|
|
#define PT_REAL_REGS(regs) ((struct pt_regs *)PT_REGS_PARM1(regs))
|
|
#else
|
|
#define PT_REAL_REGS(regs) ((regs))
|
|
#endif
|
|
|
|
#endif
|