From e6436b340c45c6def7cf46b43e92e18a0287619e Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:08:01 +0800 Subject: [PATCH] kernel: clean headers Co-authored-by: weishu --- kernel/core_hook.c | 3 +-- kernel/core_hook.h | 10 +++------- kernel/ksu.c | 8 +++----- kernel/ksud.h | 3 +++ kernel/selinux/selinux.h | 2 ++ kernel/sucompat.c | 7 ++----- kernel/sucompat.h | 8 ++++++++ kernel/supercalls.c | 9 +-------- kernel/supercalls.h | 2 ++ 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 2bf55f27..ab71e14e 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -49,8 +49,7 @@ #include "manual_su.h" #endif -bool ksu_module_mounted = false; -extern bool ksu_su_compat_enabled; +bool ksu_module_mounted __read_mostly = false; #ifdef CONFIG_COMPAT bool ksu_is_compat __read_mostly = false; diff --git a/kernel/core_hook.h b/kernel/core_hook.h index ce926b42..a3b690e5 100644 --- a/kernel/core_hook.h +++ b/kernel/core_hook.h @@ -8,14 +8,10 @@ void __init ksu_core_init(void); void ksu_core_exit(void); -#define KSU_PROC_UMOUNT 50 +void escape_to_root(void); -static inline bool ksu_is_current_proc_umounted(void) { - return test_ti_thread_flag(¤t->thread_info, KSU_PROC_UMOUNT); -} +void nuke_ext4_sysfs(void); -static inline void ksu_set_current_proc_umounted(void) { - set_ti_thread_flag(¤t->thread_info, KSU_PROC_UMOUNT); -} +extern bool ksu_module_mounted; #endif diff --git a/kernel/ksu.c b/kernel/ksu.c index e93ec652..bf920f99 100644 --- a/kernel/ksu.c +++ b/kernel/ksu.c @@ -13,12 +13,10 @@ #include "klog.h" // IWYU pragma: keep #include "ksu.h" #include "throne_tracker.h" +#include "sucompat.h" +#include "ksud.h" +#include "supercalls.h" -extern void ksu_sucompat_init(); -extern void ksu_sucompat_exit(); -extern void ksu_ksud_init(); -extern void ksu_ksud_exit(); -extern void ksu_supercalls_init(); int __init kernelsu_init(void) { #ifdef CONFIG_KSU_DEBUG diff --git a/kernel/ksud.h b/kernel/ksud.h index 7dd4cd03..62ff1030 100644 --- a/kernel/ksud.h +++ b/kernel/ksud.h @@ -3,6 +3,9 @@ #define KSUD_PATH "/data/adb/ksud" +void ksu_ksud_init(); +void ksu_ksud_exit(); + void on_post_fs_data(void); bool ksu_is_safe_mode(void); diff --git a/kernel/selinux/selinux.h b/kernel/selinux/selinux.h index 75824fc7..e458dd73 100644 --- a/kernel/selinux/selinux.h +++ b/kernel/selinux/selinux.h @@ -21,4 +21,6 @@ void apply_kernelsu_rules(); u32 ksu_get_devpts_sid(); +int handle_sepolicy(unsigned long arg3, void __user *arg4); + #endif diff --git a/kernel/sucompat.c b/kernel/sucompat.c index e909c07f..704e7943 100644 --- a/kernel/sucompat.c +++ b/kernel/sucompat.c @@ -24,16 +24,13 @@ #include "ksud.h" #include "kernel_compat.h" #include "sucompat.h" +#include "core_hook.h" #include "sulog.h" #define SU_PATH "/system/bin/su" #define SH_PATH "/system/bin/sh" -extern void escape_to_root(); -void ksu_sucompat_enable(); -void ksu_sucompat_disable(); - -bool ksu_su_compat_enabled = true; +bool ksu_su_compat_enabled __read_mostly = true; static int su_compat_feature_get(u64 *value) { diff --git a/kernel/sucompat.h b/kernel/sucompat.h index 98e70b47..b76fc54a 100644 --- a/kernel/sucompat.h +++ b/kernel/sucompat.h @@ -4,6 +4,14 @@ #include #include +extern bool ksu_su_compat_enabled; + +void ksu_sucompat_init(void); +void ksu_sucompat_exit(void); + +void ksu_sucompat_enable(void); +void ksu_sucompat_disable(void); + void ksu_mark_running_process(void); static inline void ksu_set_task_tracepoint_flag(struct task_struct *t) diff --git a/kernel/supercalls.c b/kernel/supercalls.c index b0f39e7a..f22b149e 100644 --- a/kernel/supercalls.c +++ b/kernel/supercalls.c @@ -17,6 +17,7 @@ #include "manager.h" #include "sulog.h" #include "selinux/selinux.h" +#include "core_hook.h" #include "kernel_compat.h" #include "throne_comm.h" #include "dynamic_manager.h" @@ -25,14 +26,6 @@ #include "manual_su.h" #endif -// Forward declarations from core_hook.c -extern void escape_to_root(void); -extern void nuke_ext4_sysfs(void); -extern bool ksu_module_mounted; -extern int handle_sepolicy(unsigned long arg3, void __user *arg4); -extern void ksu_sucompat_init(void); -extern void ksu_sucompat_exit(void); - bool ksu_uid_scanner_enabled = false; // Permission check functions diff --git a/kernel/supercalls.h b/kernel/supercalls.h index 6e2e887f..29a8d8cc 100644 --- a/kernel/supercalls.h +++ b/kernel/supercalls.h @@ -154,4 +154,6 @@ struct ksu_ioctl_cmd_map { // Install KSU fd to current process int ksu_install_fd(void); +void ksu_supercalls_init(); + #endif // __KSU_H_SUPERCALLS \ No newline at end of file