kernel: Resolving the issue of unavailable functionality

This commit is contained in:
ShirkNeko
2025-11-16 14:25:43 +08:00
parent 8802ea0aee
commit be63a062ad
3 changed files with 45 additions and 25 deletions

View File

@@ -70,9 +70,7 @@ int __init kernelsu_init(void)
sukisu_custom_config_init();
#if defined(CONFIG_KPROBES) && !defined(CONFIG_KSU_SUSFS)
ksu_syscall_hook_manager_init();
#endif
ksu_workqueue = alloc_ordered_workqueue("kernelsu_work_queue", 0);
@@ -109,9 +107,9 @@ void kernelsu_exit(void)
#if defined(CONFIG_KPROBES) && !defined(CONFIG_KSU_SUSFS)
ksu_ksud_exit();
#endif
ksu_syscall_hook_manager_exit();
#endif
sukisu_custom_config_exit();

View File

@@ -205,8 +205,6 @@ static const char sh_path[] = SH_PATH;
static const char su_path[] = SU_PATH;
static const char ksud_path[] = KSUD_PATH;
extern bool ksu_kernel_umount_enabled;
// the call from execve_handler_pre won't provided correct value for __never_use_argument, use them after fix execve_handler_pre, keeping them for consistence for manually patched code
int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
void *__never_use_argv, void *__never_use_envp,
@@ -214,6 +212,10 @@ int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
{
struct filename *filename;
if (!ksu_su_compat_enabled){
return 0;
}
if (unlikely(!filename_ptr))
return 0;
@@ -236,6 +238,10 @@ int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags)
{
if (!ksu_su_compat_enabled){
return 0;
}
if (ksu_handle_execveat_ksud(fd, filename_ptr, argv, envp, flags)) {
return 0;
}
@@ -248,6 +254,10 @@ int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
{
char path[sizeof(su_path) + 1] = {0};
if (!ksu_su_compat_enabled){
return 0;
}
strncpy_from_user_nofault(path, *filename_user, sizeof(path));
if (unlikely(!memcmp(path, su_path, sizeof(su_path)))) {
@@ -277,6 +287,10 @@ int ksu_handle_stat(int *dfd, struct filename **filename, int *flags) {
#else
int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
{
if (!ksu_su_compat_enabled){
return 0;
}
if (unlikely(!filename_user)) {
return 0;
}
@@ -317,6 +331,10 @@ int ksu_handle_devpts(struct inode *inode)
return 0;
}
if (!ksu_su_compat_enabled){
return 0;
}
uid_t uid = current_uid().val;
if (uid % 100000 < 10000) {
// not untrusted_app, ignore it

View File

@@ -324,6 +324,7 @@ static void ksu_sys_enter_handler(void *data, struct pt_regs *regs, long id)
void ksu_syscall_hook_manager_init(void)
{
#if defined(CONFIG_KPROBES) && !defined(CONFIG_KSU_SUSFS)
int ret;
pr_info("hook_manager: ksu_hook_manager_init called\n");
@@ -344,6 +345,7 @@ void ksu_syscall_hook_manager_init(void)
} else {
pr_info("hook_manager: sys_enter tracepoint registered\n");
}
#endif
#endif
ksu_setuid_hook_init();
@@ -352,6 +354,7 @@ void ksu_syscall_hook_manager_init(void)
void ksu_syscall_hook_manager_exit(void)
{
#if defined(CONFIG_KPROBES) && !defined(CONFIG_KSU_SUSFS)
pr_info("hook_manager: ksu_hook_manager_exit called\n");
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
unregister_trace_sys_enter(ksu_sys_enter_handler, NULL);
@@ -362,6 +365,7 @@ void ksu_syscall_hook_manager_exit(void)
#ifdef CONFIG_KRETPROBES
destroy_kretprobe(&syscall_regfunc_rp);
destroy_kretprobe(&syscall_unregfunc_rp);
#endif
#endif
ksu_sucompat_exit();