Skip to content

Commit 500ff9b

Browse files
committed
kernel: remove unused CONFIG guard becuase GKI kernel enable kprobe by default
1 parent 4593ae8 commit 500ff9b

File tree

4 files changed

+0
-60
lines changed

4 files changed

+0
-60
lines changed

kernel/core_hook.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,7 @@ void __init ksu_core_init(void)
862862

863863
void ksu_core_exit(void)
864864
{
865-
#ifdef CONFIG_KPROBES
866865
pr_info("ksu_core_kprobe_exit\n");
867866
// we dont use this now
868867
// ksu_kprobe_exit();
869-
#endif
870868
}

kernel/ksu.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ int __init kernelsu_init(void)
5757

5858
ksu_throne_tracker_init();
5959

60-
#ifdef CONFIG_KPROBES
6160
ksu_sucompat_init();
6261
ksu_ksud_init();
63-
#else
64-
pr_alert("KPROBES is disabled, KernelSU may not work, please check https://kernelsu.org/guide/how-to-integrate-for-non-gki.html");
65-
#endif
6662

6763
#ifdef MODULE
6864
#ifndef CONFIG_KSU_DEBUG
@@ -80,10 +76,8 @@ void kernelsu_exit(void)
8076

8177
destroy_workqueue(ksu_workqueue);
8278

83-
#ifdef CONFIG_KPROBES
8479
ksu_ksud_exit();
8580
ksu_sucompat_exit();
86-
#endif
8781

8882
ksu_core_exit();
8983
}

kernel/ksud.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ static void stop_vfs_read_hook();
4747
static void stop_execve_hook();
4848
static void stop_input_hook();
4949

50-
#ifdef CONFIG_KPROBES
5150
static struct work_struct stop_vfs_read_work;
5251
static struct work_struct stop_execve_hook_work;
5352
static struct work_struct stop_input_hook_work;
54-
#else
55-
bool ksu_vfs_read_hook __read_mostly = true;
56-
bool ksu_execveat_hook __read_mostly = true;
57-
bool ksu_input_hook __read_mostly = true;
58-
#endif
5953

6054
u32 ksu_devpts_sid;
6155

@@ -150,11 +144,6 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
150144
struct user_arg_ptr *argv,
151145
struct user_arg_ptr *envp, int *flags)
152146
{
153-
#ifndef CONFIG_KPROBES
154-
if (!ksu_execveat_hook) {
155-
return 0;
156-
}
157-
#endif
158147
struct filename *filename;
159148

160149
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)
306295
int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr,
307296
size_t *count_ptr, loff_t **pos)
308297
{
309-
#ifndef CONFIG_KPROBES
310-
if (!ksu_vfs_read_hook) {
311-
return 0;
312-
}
313-
#endif
314298
struct file *file;
315299
char __user *buf;
316300
size_t count;
@@ -419,11 +403,6 @@ static bool is_volumedown_enough(unsigned int count)
419403
int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code,
420404
int *value)
421405
{
422-
#ifndef CONFIG_KPROBES
423-
if (!ksu_input_hook) {
424-
return 0;
425-
}
426-
#endif
427406
if (*type == EV_KEY && *code == KEY_VOLUMEDOWN) {
428407
int val = *value;
429408
pr_info("KEY_VOLUMEDOWN val: %d\n", val);
@@ -461,8 +440,6 @@ bool ksu_is_safe_mode()
461440
return false;
462441
}
463442

464-
#ifdef CONFIG_KPROBES
465-
466443
static int sys_execve_handler_pre(struct kprobe *p, struct pt_regs *regs)
467444
{
468445
struct pt_regs *real_regs = PT_REAL_REGS(regs);
@@ -515,7 +492,6 @@ static struct kprobe vfs_read_kp = {
515492
.pre_handler = sys_read_handler_pre,
516493
};
517494

518-
519495
static struct kprobe input_event_kp = {
520496
.symbol_name = "input_event",
521497
.pre_handler = input_handle_event_handler_pre,
@@ -535,28 +511,17 @@ static void do_stop_input_hook(struct work_struct *work)
535511
{
536512
unregister_kprobe(&input_event_kp);
537513
}
538-
#endif
539514

540515
static void stop_vfs_read_hook()
541516
{
542-
#ifdef CONFIG_KPROBES
543517
bool ret = schedule_work(&stop_vfs_read_work);
544518
pr_info("unregister vfs_read kprobe: %d!\n", ret);
545-
#else
546-
ksu_vfs_read_hook = false;
547-
pr_info("stop vfs_read_hook\n");
548-
#endif
549519
}
550520

551521
static void stop_execve_hook()
552522
{
553-
#ifdef CONFIG_KPROBES
554523
bool ret = schedule_work(&stop_execve_hook_work);
555524
pr_info("unregister execve kprobe: %d!\n", ret);
556-
#else
557-
ksu_execveat_hook = false;
558-
pr_info("stop execve_hook\n");
559-
#endif
560525
}
561526

562527
static void stop_input_hook()
@@ -566,19 +531,13 @@ static void stop_input_hook()
566531
return;
567532
}
568533
input_hook_stopped = true;
569-
#ifdef CONFIG_KPROBES
570534
bool ret = schedule_work(&stop_input_hook_work);
571535
pr_info("unregister input kprobe: %d!\n", ret);
572-
#else
573-
ksu_input_hook = false;
574-
pr_info("stop input_hook\n");
575-
#endif
576536
}
577537

578538
// ksud: module support
579539
void ksu_ksud_init()
580540
{
581-
#ifdef CONFIG_KPROBES
582541
int ret;
583542

584543
ret = register_kprobe(&execve_kp);
@@ -593,15 +552,12 @@ void ksu_ksud_init()
593552
INIT_WORK(&stop_vfs_read_work, do_stop_vfs_read_hook);
594553
INIT_WORK(&stop_execve_hook_work, do_stop_execve_hook);
595554
INIT_WORK(&stop_input_hook_work, do_stop_input_hook);
596-
#endif
597555
}
598556

599557
void ksu_ksud_exit()
600558
{
601-
#ifdef CONFIG_KPROBES
602559
unregister_kprobe(&execve_kp);
603560
// this should be done before unregister vfs_read_kp
604561
// unregister_kprobe(&vfs_read_kp);
605562
unregister_kprobe(&input_event_kp);
606-
#endif
607563
}

kernel/sucompat.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ int ksu_handle_devpts(struct inode *inode)
189189
return 0;
190190
}
191191

192-
#ifdef CONFIG_KPROBES
193-
194192
static int faccessat_handler_pre(struct kprobe *p, struct pt_regs *regs)
195193
{
196194
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)
232230
return ksu_handle_devpts(inode);
233231
}
234232

235-
#endif
236-
237233
static struct kprobe *init_kprobe(const char *name,
238234
kprobe_pre_handler_t handler)
239235
{
@@ -269,19 +265,15 @@ static struct kprobe *su_kps[4];
269265
// sucompat: permited process can execute 'su' to gain root access.
270266
void ksu_sucompat_init()
271267
{
272-
#ifdef CONFIG_KPROBES
273268
su_kps[0] = init_kprobe(SYS_EXECVE_SYMBOL, execve_handler_pre);
274269
su_kps[1] = init_kprobe(SYS_FACCESSAT_SYMBOL, faccessat_handler_pre);
275270
su_kps[2] = init_kprobe(SYS_NEWFSTATAT_SYMBOL, newfstatat_handler_pre);
276271
su_kps[3] = init_kprobe("pts_unix98_lookup", pts_unix98_lookup_pre);
277-
#endif
278272
}
279273

280274
void ksu_sucompat_exit()
281275
{
282-
#ifdef CONFIG_KPROBES
283276
for (int i = 0; i < ARRAY_SIZE(su_kps); i++) {
284277
destroy_kprobe(&su_kps[i]);
285278
}
286-
#endif
287279
}

0 commit comments

Comments
 (0)