kernel: remove unused CONFIG guard becuase GKI kernel enable kprobe by default
Some checks failed
Build Manager / build-lkm (push) Waiting to run
Build Manager / build-ksud (macos-latest, aarch64-apple-darwin) (push) Blocked by required conditions
Build Manager / build-ksud (macos-latest, x86_64-apple-darwin) (push) Blocked by required conditions
Build Manager / build-ksud (ubuntu-latest, aarch64-linux-android) (push) Blocked by required conditions
Build Manager / build-ksud (ubuntu-latest, aarch64-unknown-linux-musl) (push) Blocked by required conditions
Build Manager / build-ksud (ubuntu-latest, x86_64-linux-android) (push) Blocked by required conditions
Build Manager / build-ksud (ubuntu-latest, x86_64-pc-windows-gnu) (push) Blocked by required conditions
Build Manager / build-ksud (ubuntu-latest, x86_64-unknown-linux-musl) (push) Blocked by required conditions
Build Manager / build-manager (push) Blocked by required conditions
Build Kernel - Android 12 / build-kernel (2024-05, 209) (push) Has been cancelled
Build Kernel - Android 12 / build-kernel (2024-08, 218) (push) Has been cancelled
Build Kernel - Android 12 / build-kernel (2024-11, 226) (push) Has been cancelled
Build Kernel - Android 12 / check-build-kernel (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-05, 148, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-05, 209, 5.10) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-06, 210, 5.10) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-07, 149, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-07, 214, 5.10) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-08, 151, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-08, 218, 5.10) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-09, 153, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-11, 167, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / build-kernel (2024-11, 223, 5.10) (push) Has been cancelled
Build Kernel - Android 13 / check-build-kernel (2024-11, 167, 5.15) (push) Has been cancelled
Build Kernel - Android 13 / check-build-kernel (2024-11, 223, 5.10) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-05, 148, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-05, 75, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-06, 149, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-06, 78, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-07, 153, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-07, 84, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-08, 158, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-08, 90, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-09, 164, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-09, 93, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-10, 99, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-11, 112, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-11, 167, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / build-kernel (2024-12, 115, 6.1) (push) Has been cancelled
Build Kernel - Android 14 / check-build-kernel (2024-11, 167, 5.15) (push) Has been cancelled
Build Kernel - Android 14 / check-build-kernel (2024-12, 115, 6.1) (push) Has been cancelled
Build Kernel - Android 15 / build-kernel (2024-08, 30, 6.6) (push) Has been cancelled
Build Kernel - Android 15 / build-kernel (2024-09, 46, 6.6) (push) Has been cancelled
Build Kernel - Android 15 / build-kernel (2024-10, 50, 6.6) (push) Has been cancelled
Build Kernel - Android 15 / build-kernel (2024-11, 56, 6.6) (push) Has been cancelled
Build Kernel - Android 15 / build-kernel (2024-12, 57, 6.6) (push) Has been cancelled
Build Kernel - Android 15 / check-build-kernel (2024-12, 57, 6.6) (push) Has been cancelled
Build Kernel - ChromeOS ARCVM / Build ChromeOS ARCVM kernel (arm64, build.config.gki.aarch64, arm64_arcvm_defconfig, Image) (push) Has been cancelled
Build Kernel - ChromeOS ARCVM / Build ChromeOS ARCVM kernel (x86_64, build.config.gki.x86_64, x86_64_arcvm_defconfig, bzImage) (push) Has been cancelled
Build Kernel - AVD / build-kernel (aarch64, android-15-avd_aarch64.xml, android-15-avd_aarch64) (push) Has been cancelled
Build Kernel - AVD / build-kernel (x86_64, android-14-avd_x86_64.xml, android-14-avd_x86_64) (push) Has been cancelled
Build Kernel - AVD / build-kernel (x86_64, android-15-avd_x86_64.xml, android-15-avd_x86_64) (push) Has been cancelled
Build Kernel - WSA / build (arm64, 5.15.104.1) (push) Has been cancelled
Build Kernel - WSA / build (arm64, 5.15.104.2) (push) Has been cancelled
Build Kernel - WSA / build (arm64, 5.15.104.3) (push) Has been cancelled
Build Kernel - WSA / build (arm64, 5.15.104.4) (push) Has been cancelled
Build Kernel - WSA / build (arm64, 5.15.94.2) (push) Has been cancelled
Build Kernel - WSA / build (x86_64, 5.15.104.1) (push) Has been cancelled
Build Kernel - WSA / build (x86_64, 5.15.104.2) (push) Has been cancelled
Build Kernel - WSA / build (x86_64, 5.15.104.3) (push) Has been cancelled
Build Kernel - WSA / build (x86_64, 5.15.104.4) (push) Has been cancelled
Build Kernel - WSA / build (x86_64, 5.15.94.2) (push) Has been cancelled
Build Kernel - WSA / check_build (arm64) (push) Has been cancelled
Build Kernel - WSA / check_build (x86_64) (push) Has been cancelled
Build Kernel - Android 12 / upload-artifacts (push) Has been cancelled
Build Kernel - Android 13 / upload-artifacts (push) Has been cancelled
Build Kernel - Android 14 / upload-artifacts (push) Has been cancelled
Build Kernel - Android 15 / upload-artifacts (push) Has been cancelled

This commit is contained in:
weishu 2025-02-16 21:38:59 +08:00
parent 4593ae81c7
commit 500ff9bcbc
4 changed files with 0 additions and 60 deletions

View File

@ -862,9 +862,7 @@ void __init ksu_core_init(void)
void ksu_core_exit(void)
{
#ifdef CONFIG_KPROBES
pr_info("ksu_core_kprobe_exit\n");
// we dont use this now
// ksu_kprobe_exit();
#endif
}

View File

@ -57,12 +57,8 @@ int __init kernelsu_init(void)
ksu_throne_tracker_init();
#ifdef CONFIG_KPROBES
ksu_sucompat_init();
ksu_ksud_init();
#else
pr_alert("KPROBES is disabled, KernelSU may not work, please check https://kernelsu.org/guide/how-to-integrate-for-non-gki.html");
#endif
#ifdef MODULE
#ifndef CONFIG_KSU_DEBUG
@ -80,10 +76,8 @@ void kernelsu_exit(void)
destroy_workqueue(ksu_workqueue);
#ifdef CONFIG_KPROBES
ksu_ksud_exit();
ksu_sucompat_exit();
#endif
ksu_core_exit();
}

View File

@ -47,15 +47,9 @@ static void stop_vfs_read_hook();
static void stop_execve_hook();
static void stop_input_hook();
#ifdef CONFIG_KPROBES
static struct work_struct stop_vfs_read_work;
static struct work_struct stop_execve_hook_work;
static struct work_struct stop_input_hook_work;
#else
bool ksu_vfs_read_hook __read_mostly = true;
bool ksu_execveat_hook __read_mostly = true;
bool ksu_input_hook __read_mostly = true;
#endif
u32 ksu_devpts_sid;
@ -150,11 +144,6 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
struct user_arg_ptr *argv,
struct user_arg_ptr *envp, int *flags)
{
#ifndef CONFIG_KPROBES
if (!ksu_execveat_hook) {
return 0;
}
#endif
struct filename *filename;
static const char app_process[] = "/system/bin/app_process";
@ -306,11 +295,6 @@ static ssize_t read_iter_proxy(struct kiocb *iocb, struct iov_iter *to)
int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr,
size_t *count_ptr, loff_t **pos)
{
#ifndef CONFIG_KPROBES
if (!ksu_vfs_read_hook) {
return 0;
}
#endif
struct file *file;
char __user *buf;
size_t count;
@ -419,11 +403,6 @@ static bool is_volumedown_enough(unsigned int count)
int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code,
int *value)
{
#ifndef CONFIG_KPROBES
if (!ksu_input_hook) {
return 0;
}
#endif
if (*type == EV_KEY && *code == KEY_VOLUMEDOWN) {
int val = *value;
pr_info("KEY_VOLUMEDOWN val: %d\n", val);
@ -461,8 +440,6 @@ bool ksu_is_safe_mode()
return false;
}
#ifdef CONFIG_KPROBES
static int sys_execve_handler_pre(struct kprobe *p, struct pt_regs *regs)
{
struct pt_regs *real_regs = PT_REAL_REGS(regs);
@ -515,7 +492,6 @@ static struct kprobe vfs_read_kp = {
.pre_handler = sys_read_handler_pre,
};
static struct kprobe input_event_kp = {
.symbol_name = "input_event",
.pre_handler = input_handle_event_handler_pre,
@ -535,28 +511,17 @@ static void do_stop_input_hook(struct work_struct *work)
{
unregister_kprobe(&input_event_kp);
}
#endif
static void stop_vfs_read_hook()
{
#ifdef CONFIG_KPROBES
bool ret = schedule_work(&stop_vfs_read_work);
pr_info("unregister vfs_read kprobe: %d!\n", ret);
#else
ksu_vfs_read_hook = false;
pr_info("stop vfs_read_hook\n");
#endif
}
static void stop_execve_hook()
{
#ifdef CONFIG_KPROBES
bool ret = schedule_work(&stop_execve_hook_work);
pr_info("unregister execve kprobe: %d!\n", ret);
#else
ksu_execveat_hook = false;
pr_info("stop execve_hook\n");
#endif
}
static void stop_input_hook()
@ -566,19 +531,13 @@ static void stop_input_hook()
return;
}
input_hook_stopped = true;
#ifdef CONFIG_KPROBES
bool ret = schedule_work(&stop_input_hook_work);
pr_info("unregister input kprobe: %d!\n", ret);
#else
ksu_input_hook = false;
pr_info("stop input_hook\n");
#endif
}
// ksud: module support
void ksu_ksud_init()
{
#ifdef CONFIG_KPROBES
int ret;
ret = register_kprobe(&execve_kp);
@ -593,15 +552,12 @@ void ksu_ksud_init()
INIT_WORK(&stop_vfs_read_work, do_stop_vfs_read_hook);
INIT_WORK(&stop_execve_hook_work, do_stop_execve_hook);
INIT_WORK(&stop_input_hook_work, do_stop_input_hook);
#endif
}
void ksu_ksud_exit()
{
#ifdef CONFIG_KPROBES
unregister_kprobe(&execve_kp);
// this should be done before unregister vfs_read_kp
// unregister_kprobe(&vfs_read_kp);
unregister_kprobe(&input_event_kp);
#endif
}

View File

@ -189,8 +189,6 @@ int ksu_handle_devpts(struct inode *inode)
return 0;
}
#ifdef CONFIG_KPROBES
static int faccessat_handler_pre(struct kprobe *p, struct pt_regs *regs)
{
struct pt_regs *real_regs = PT_REAL_REGS(regs);
@ -232,8 +230,6 @@ static int pts_unix98_lookup_pre(struct kprobe *p, struct pt_regs *regs)
return ksu_handle_devpts(inode);
}
#endif
static struct kprobe *init_kprobe(const char *name,
kprobe_pre_handler_t handler)
{
@ -269,19 +265,15 @@ static struct kprobe *su_kps[4];
// sucompat: permited process can execute 'su' to gain root access.
void ksu_sucompat_init()
{
#ifdef CONFIG_KPROBES
su_kps[0] = init_kprobe(SYS_EXECVE_SYMBOL, execve_handler_pre);
su_kps[1] = init_kprobe(SYS_FACCESSAT_SYMBOL, faccessat_handler_pre);
su_kps[2] = init_kprobe(SYS_NEWFSTATAT_SYMBOL, newfstatat_handler_pre);
su_kps[3] = init_kprobe("pts_unix98_lookup", pts_unix98_lookup_pre);
#endif
}
void ksu_sucompat_exit()
{
#ifdef CONFIG_KPROBES
for (int i = 0; i < ARRAY_SIZE(su_kps); i++) {
destroy_kprobe(&su_kps[i]);
}
#endif
}