mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
kernel: clean memory when exit
This commit is contained in:
parent
5167dc7352
commit
858ec910fd
@ -838,5 +838,9 @@ void __init ksu_core_init(void)
|
|||||||
|
|
||||||
void ksu_core_exit(void)
|
void ksu_core_exit(void)
|
||||||
{
|
{
|
||||||
pr_info("ksu_kprobe_exit\n");
|
#ifdef CONFIG_KPROBES
|
||||||
|
pr_info("ksu_core_kprobe_exit\n");
|
||||||
|
// we dont use this now
|
||||||
|
// ksu_kprobe_exit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
15
kernel/ksu.c
15
kernel/ksu.c
@ -32,8 +32,10 @@ int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
|
|||||||
flags);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void ksu_enable_sucompat();
|
extern void ksu_sucompat_init();
|
||||||
extern void ksu_enable_ksud();
|
extern void ksu_sucompat_exit();
|
||||||
|
extern void ksu_ksud_init();
|
||||||
|
extern void ksu_ksud_exit();
|
||||||
|
|
||||||
int __init kernelsu_init(void)
|
int __init kernelsu_init(void)
|
||||||
{
|
{
|
||||||
@ -56,8 +58,8 @@ int __init kernelsu_init(void)
|
|||||||
ksu_throne_tracker_init();
|
ksu_throne_tracker_init();
|
||||||
|
|
||||||
#ifdef CONFIG_KPROBES
|
#ifdef CONFIG_KPROBES
|
||||||
ksu_enable_sucompat();
|
ksu_sucompat_init();
|
||||||
ksu_enable_ksud();
|
ksu_ksud_init();
|
||||||
#else
|
#else
|
||||||
pr_alert("KPROBES is disabled, KernelSU may not work, please check https://kernelsu.org/guide/how-to-integrate-for-non-gki.html");
|
pr_alert("KPROBES is disabled, KernelSU may not work, please check https://kernelsu.org/guide/how-to-integrate-for-non-gki.html");
|
||||||
#endif
|
#endif
|
||||||
@ -78,6 +80,11 @@ void kernelsu_exit(void)
|
|||||||
|
|
||||||
destroy_workqueue(ksu_workqueue);
|
destroy_workqueue(ksu_workqueue);
|
||||||
|
|
||||||
|
#ifdef CONFIG_KPROBES
|
||||||
|
ksu_ksud_exit();
|
||||||
|
ksu_sucompat_exit();
|
||||||
|
#endif
|
||||||
|
|
||||||
ksu_core_exit();
|
ksu_core_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ static void stop_input_hook()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ksud: module support
|
// ksud: module support
|
||||||
void ksu_enable_ksud()
|
void ksu_ksud_init()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KPROBES
|
#ifdef CONFIG_KPROBES
|
||||||
int ret;
|
int ret;
|
||||||
@ -608,3 +608,12 @@ void ksu_enable_ksud()
|
|||||||
INIT_WORK(&stop_input_hook_work, do_stop_input_hook);
|
INIT_WORK(&stop_input_hook_work, do_stop_input_hook);
|
||||||
#endif
|
#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_handle_event_kp);
|
||||||
|
#endif
|
||||||
|
}
|
@ -242,7 +242,7 @@ static struct kprobe execve_kp = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sucompat: permited process can execute 'su' to gain root access.
|
// sucompat: permited process can execute 'su' to gain root access.
|
||||||
void ksu_enable_sucompat()
|
void ksu_sucompat_init()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KPROBES
|
#ifdef CONFIG_KPROBES
|
||||||
int ret;
|
int ret;
|
||||||
@ -254,3 +254,11 @@ void ksu_enable_sucompat()
|
|||||||
pr_info("sucompat: faccessat_kp: %d\n", ret);
|
pr_info("sucompat: faccessat_kp: %d\n", ret);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ksu_sucompat_exit() {
|
||||||
|
#ifdef CONFIG_KPROBES
|
||||||
|
unregister_kprobe(&execve_kp);
|
||||||
|
unregister_kprobe(&newfstatat_kp);
|
||||||
|
unregister_kprobe(&faccessat_kp);
|
||||||
|
#endif
|
||||||
|
}
|
@ -308,13 +308,12 @@ void track_throne()
|
|||||||
ksu_queue_work(&ksu_update_uid_work);
|
ksu_queue_work(&ksu_update_uid_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ksu_throne_tracker_init()
|
void ksu_throne_tracker_init()
|
||||||
{
|
{
|
||||||
INIT_WORK(&ksu_update_uid_work, do_update_uid);
|
INIT_WORK(&ksu_update_uid_work, do_update_uid);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ksu_throne_tracker_exit()
|
void ksu_throne_tracker_exit()
|
||||||
{
|
{
|
||||||
return 0;
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef __KSU_H_UID_OBSERVER
|
#ifndef __KSU_H_UID_OBSERVER
|
||||||
#define __KSU_H_UID_OBSERVER
|
#define __KSU_H_UID_OBSERVER
|
||||||
|
|
||||||
int ksu_throne_tracker_init();
|
void ksu_throne_tracker_init();
|
||||||
|
|
||||||
int ksu_throne_tracker_exit();
|
void ksu_throne_tracker_exit();
|
||||||
|
|
||||||
void track_throne();
|
void track_throne();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user