* refact
* sort inlude
* update
* unregister execve kprobe
* update log
* don't unregister if not in kprobe
* opt for no kprobe
* opt for no kprobe
* stop debug
* don't forget to call ksu_uid_observer_exit
* rename core to core_hook
* direct call do_persistent_allow_list
* add prefix
* use getter, add warn
* add wrapper
* run clang-format
clang-format --style="{BasedOnStyle: InheritParentConfig, SortIncludes: true}" -i kernel/**/*.[ch]
* try fix wsa x64 build
87 lines
2.2 KiB
C
87 lines
2.2 KiB
C
#include "linux/module.h"
|
|
#include "linux/workqueue.h"
|
|
#include "linux/fs.h"
|
|
|
|
#include "allowlist.h"
|
|
#include "arch.h"
|
|
#include "core_hook.h"
|
|
#include "ksu.h"
|
|
#include "uid_observer.h"
|
|
|
|
static struct workqueue_struct *ksu_workqueue;
|
|
|
|
bool ksu_queue_work(struct work_struct *work)
|
|
{
|
|
return queue_work(ksu_workqueue, work);
|
|
}
|
|
|
|
extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
|
|
void *argv, void *envp, int *flags);
|
|
|
|
extern int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
|
|
void *argv, void *envp, int *flags);
|
|
|
|
int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
|
|
void *envp, int *flags)
|
|
{
|
|
ksu_handle_execveat_ksud(fd, filename_ptr, argv, envp, flags);
|
|
return ksu_handle_execveat_sucompat(fd, filename_ptr, argv, envp,
|
|
flags);
|
|
}
|
|
|
|
extern void ksu_enable_sucompat();
|
|
extern void ksu_enable_ksud();
|
|
|
|
int __init kernelsu_init(void)
|
|
{
|
|
#ifdef CONFIG_KSU_DEBUG
|
|
pr_alert(
|
|
"*************************************************************\n"
|
|
"** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"
|
|
"** **\n"
|
|
"** You are running DEBUG version of KernelSU **\n"
|
|
"** **\n"
|
|
"** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"
|
|
"*************************************************************\n");
|
|
#endif
|
|
|
|
ksu_core_init();
|
|
|
|
ksu_workqueue = alloc_workqueue("kernelsu_work_queue", 0, 0);
|
|
|
|
ksu_allowlist_init();
|
|
|
|
ksu_uid_observer_init();
|
|
|
|
#ifdef CONFIG_KPROBES
|
|
ksu_enable_sucompat();
|
|
ksu_enable_ksud();
|
|
#else
|
|
#warning("KPROBES is disabled, KernelSU may not work, please check https://kernelsu.org/guide/how-to-integrate-for-non-gki.html")
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
void kernelsu_exit(void)
|
|
{
|
|
ksu_allowlist_exit();
|
|
|
|
ksu_uid_observer_exit();
|
|
|
|
destroy_workqueue(ksu_workqueue);
|
|
|
|
ksu_core_exit();
|
|
}
|
|
|
|
module_init(kernelsu_init);
|
|
module_exit(kernelsu_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("weishu");
|
|
MODULE_DESCRIPTION("Android KernelSU");
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
|
|
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
|
|
#endif
|