@@ -47,9 +47,15 @@ static void stop_vfs_read_hook();
47
47
static void stop_execve_hook ();
48
48
static void stop_input_hook ();
49
49
50
+ #ifdef CONFIG_KPROBES
50
51
static struct work_struct stop_vfs_read_work ;
51
52
static struct work_struct stop_execve_hook_work ;
52
53
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
53
59
54
60
u32 ksu_devpts_sid ;
55
61
@@ -144,6 +150,11 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
144
150
struct user_arg_ptr * argv ,
145
151
struct user_arg_ptr * envp , int * flags )
146
152
{
153
+ #ifndef CONFIG_KPROBES
154
+ if (!ksu_execveat_hook ) {
155
+ return 0 ;
156
+ }
157
+ #endif
147
158
struct filename * filename ;
148
159
149
160
static const char app_process [] = "/system/bin/app_process" ;
@@ -295,6 +306,11 @@ static ssize_t read_iter_proxy(struct kiocb *iocb, struct iov_iter *to)
295
306
int ksu_handle_vfs_read (struct file * * file_ptr , char __user * * buf_ptr ,
296
307
size_t * count_ptr , loff_t * * pos )
297
308
{
309
+ #ifndef CONFIG_KPROBES
310
+ if (!ksu_vfs_read_hook ) {
311
+ return 0 ;
312
+ }
313
+ #endif
298
314
struct file * file ;
299
315
char __user * buf ;
300
316
size_t count ;
@@ -403,6 +419,11 @@ static bool is_volumedown_enough(unsigned int count)
403
419
int ksu_handle_input_handle_event (unsigned int * type , unsigned int * code ,
404
420
int * value )
405
421
{
422
+ #ifndef CONFIG_KPROBES
423
+ if (!ksu_input_hook ) {
424
+ return 0 ;
425
+ }
426
+ #endif
406
427
if (* type == EV_KEY && * code == KEY_VOLUMEDOWN ) {
407
428
int val = * value ;
408
429
pr_info ("KEY_VOLUMEDOWN val: %d\n" , val );
@@ -440,6 +461,8 @@ bool ksu_is_safe_mode()
440
461
return false;
441
462
}
442
463
464
+ #ifdef CONFIG_KPROBES
465
+
443
466
static int sys_execve_handler_pre (struct kprobe * p , struct pt_regs * regs )
444
467
{
445
468
struct pt_regs * real_regs = PT_REAL_REGS (regs );
@@ -492,6 +515,7 @@ static struct kprobe vfs_read_kp = {
492
515
.pre_handler = sys_read_handler_pre ,
493
516
};
494
517
518
+
495
519
static struct kprobe input_event_kp = {
496
520
.symbol_name = "input_event" ,
497
521
.pre_handler = input_handle_event_handler_pre ,
@@ -511,17 +535,28 @@ static void do_stop_input_hook(struct work_struct *work)
511
535
{
512
536
unregister_kprobe (& input_event_kp );
513
537
}
538
+ #endif
514
539
515
540
static void stop_vfs_read_hook ()
516
541
{
542
+ #ifdef CONFIG_KPROBES
517
543
bool ret = schedule_work (& stop_vfs_read_work );
518
544
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
519
549
}
520
550
521
551
static void stop_execve_hook ()
522
552
{
553
+ #ifdef CONFIG_KPROBES
523
554
bool ret = schedule_work (& stop_execve_hook_work );
524
555
pr_info ("unregister execve kprobe: %d!\n" , ret );
556
+ #else
557
+ ksu_execveat_hook = false;
558
+ pr_info ("stop execve_hook\n" );
559
+ #endif
525
560
}
526
561
527
562
static void stop_input_hook ()
@@ -531,13 +566,19 @@ static void stop_input_hook()
531
566
return ;
532
567
}
533
568
input_hook_stopped = true;
569
+ #ifdef CONFIG_KPROBES
534
570
bool ret = schedule_work (& stop_input_hook_work );
535
571
pr_info ("unregister input kprobe: %d!\n" , ret );
572
+ #else
573
+ ksu_input_hook = false;
574
+ pr_info ("stop input_hook\n" );
575
+ #endif
536
576
}
537
577
538
578
// ksud: module support
539
579
void ksu_ksud_init ()
540
580
{
581
+ #ifdef CONFIG_KPROBES
541
582
int ret ;
542
583
543
584
ret = register_kprobe (& execve_kp );
@@ -552,12 +593,15 @@ void ksu_ksud_init()
552
593
INIT_WORK (& stop_vfs_read_work , do_stop_vfs_read_hook );
553
594
INIT_WORK (& stop_execve_hook_work , do_stop_execve_hook );
554
595
INIT_WORK (& stop_input_hook_work , do_stop_input_hook );
596
+ #endif
555
597
}
556
598
557
599
void ksu_ksud_exit ()
558
600
{
601
+ #ifdef CONFIG_KPROBES
559
602
unregister_kprobe (& execve_kp );
560
603
// this should be done before unregister vfs_read_kp
561
604
// unregister_kprobe(&vfs_read_kp);
562
605
unregister_kprobe (& input_event_kp );
606
+ #endif
563
607
}
0 commit comments