feat: try manual reboot hook (#521)

* feat: try manual reboot hook

* refactor: move ksu_handle_reboot to supercalls.c for ShirkNeko

---------
This commit is contained in:
AlexLiuDev233
2025-11-04 01:08:49 +08:00
committed by GitHub
parent d286f49e11
commit 1853d9decf
3 changed files with 45 additions and 9 deletions

View File

@@ -649,6 +649,8 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
return 0;
}
extern void ksu_handle_reboot(int magic1, int magic2, void __user * arg); // supercalls.c
// Init functons - kprobe hooks
// 1. Reboot hook for installing fd
@@ -660,15 +662,8 @@ static int reboot_handler_pre(struct kprobe *p, struct pt_regs *regs)
unsigned long arg4;
// Check if this is a request to install KSU fd
if (magic1 == KSU_INSTALL_MAGIC1 && magic2 == KSU_INSTALL_MAGIC2) {
int fd = ksu_install_fd();
pr_info("[%d] install ksu fd: %d\n", current->pid, fd);
arg4 = (unsigned long)PT_REGS_SYSCALL_PARM4(real_regs);
if (copy_to_user((int *)arg4, &fd, sizeof(fd))) {
pr_err("install ksu fd reply err\n");
}
}
arg4 = (unsigned long)PT_REGS_SYSCALL_PARM4(real_regs);
ksu_handle_reboot(magic1, magic2, (void __user *) arg4);
return 0;
}

View File

@@ -69,6 +69,17 @@ static void init_uid_scanner(void)
}
}
void ksu_handle_reboot(int magic1, int magic2, void __user * arg) {
if (magic1 == KSU_INSTALL_MAGIC1 && magic2 == KSU_INSTALL_MAGIC2) {
int fd = ksu_install_fd();
pr_info("[%d] install ksu fd: %d\n", current->pid, fd);
if (copy_to_user(arg, &fd, sizeof(fd))) {
pr_err("install ksu fd reply err\n");
}
}
}
static int do_grant_root(void __user *arg)
{
// Check if current UID is allowed