From 76046c84cdab0fb5bf841905713201e7d704bb34 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Sat, 8 Nov 2025 19:39:41 +0800 Subject: [PATCH] kernel: remove unused kernel_compat Co-authored-by: weishu --- kernel/Makefile | 2 +- kernel/allowlist.c | 1 - kernel/apk_sign.c | 1 - kernel/core_hook.c | 5 ++--- kernel/dynamic_manager.c | 1 - kernel/kernel_compat.h | 5 ----- kernel/ksu.c | 1 - kernel/ksud.c | 1 + kernel/manual_su.c | 1 - kernel/{kernel_compat.c => seccomp_cache.c} | 2 +- kernel/seccomp_cache.h | 12 ++++++++++++ kernel/selinux/sepolicy.c | 1 - kernel/sucompat.c | 1 - kernel/sulog.c | 1 - kernel/supercalls.c | 1 - kernel/throne_comm.c | 1 - kernel/throne_tracker.c | 1 - 17 files changed, 17 insertions(+), 21 deletions(-) rename kernel/{kernel_compat.c => seccomp_cache.c} (98%) create mode 100644 kernel/seccomp_cache.h diff --git a/kernel/Makefile b/kernel/Makefile index d6477d16..32b5a142 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -11,7 +11,7 @@ kernelsu-objs += supercalls.o kernelsu-objs += feature.o kernelsu-objs += ksud.o kernelsu-objs += embed_ksud.o -kernelsu-objs += kernel_compat.o +kernelsu-objs += seccomp_cache.o kernelsu-objs += file_wrapper.o kernelsu-objs += throne_comm.o kernelsu-objs += sulog.o diff --git a/kernel/allowlist.c b/kernel/allowlist.c index 1e290c79..f809c529 100644 --- a/kernel/allowlist.c +++ b/kernel/allowlist.c @@ -15,7 +15,6 @@ #include "ksu.h" #include "klog.h" // IWYU pragma: keep #include "selinux/selinux.h" -#include "kernel_compat.h" #include "allowlist.h" #include "manager.h" diff --git a/kernel/apk_sign.c b/kernel/apk_sign.c index 27f6c764..1d499851 100644 --- a/kernel/apk_sign.c +++ b/kernel/apk_sign.c @@ -17,7 +17,6 @@ #include "apk_sign.h" #include "dynamic_manager.h" #include "klog.h" // IWYU pragma: keep -#include "kernel_compat.h" #include "manager_sign.h" struct sdesc { diff --git a/kernel/core_hook.c b/kernel/core_hook.c index cb54978d..bf264ed2 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -37,14 +37,13 @@ #include "feature.h" #include "klog.h" // IWYU pragma: keep #include "ksu.h" -#include "ksud.h" #include "manager.h" #include "selinux/selinux.h" -#include "kernel_compat.h" #include "supercalls.h" #include "sucompat.h" #include "sulog.h" -#include "throne_tracker.h" +#include "seccomp_cache.h" + #include "throne_comm.h" #include "umount_manager.h" diff --git a/kernel/dynamic_manager.c b/kernel/dynamic_manager.c index 14f6c794..96bc710b 100644 --- a/kernel/dynamic_manager.c +++ b/kernel/dynamic_manager.c @@ -17,7 +17,6 @@ #include "dynamic_manager.h" #include "klog.h" // IWYU pragma: keep -#include "kernel_compat.h" #include "manager.h" #define MAX_MANAGERS 2 diff --git a/kernel/kernel_compat.h b/kernel/kernel_compat.h index 8b4e1061..14e1cb23 100644 --- a/kernel/kernel_compat.h +++ b/kernel/kernel_compat.h @@ -21,9 +21,4 @@ static long ksu_copy_from_user_retry(void *to, return copy_from_user(to, from, count); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 2) // Android backport this feature in 5.10.2 -extern void ksu_seccomp_clear_cache(struct seccomp_filter *filter, int nr); -extern void ksu_seccomp_allow_cache(struct seccomp_filter *filter, int nr); -#endif - #endif diff --git a/kernel/ksu.c b/kernel/ksu.c index e77b50fb..90edaced 100644 --- a/kernel/ksu.c +++ b/kernel/ksu.c @@ -7,7 +7,6 @@ #include "allowlist.h" #include "arch.h" -#include "kernel_compat.h" #include "core_hook.h" #include "feature.h" #include "klog.h" // IWYU pragma: keep diff --git a/kernel/ksud.c b/kernel/ksud.c index 818320c7..e2a25c57 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -21,6 +21,7 @@ #include "arch.h" #include "klog.h" // IWYU pragma: keep #include "ksud.h" + #include "kernel_compat.h" #include "selinux/selinux.h" #include "sucompat.h" diff --git a/kernel/manual_su.c b/kernel/manual_su.c index b082f56b..e7e60f52 100644 --- a/kernel/manual_su.c +++ b/kernel/manual_su.c @@ -7,7 +7,6 @@ #include #include #include -#include "kernel_compat.h" #include "manual_su.h" #include "ksu.h" #include "allowlist.h" diff --git a/kernel/kernel_compat.c b/kernel/seccomp_cache.c similarity index 98% rename from kernel/kernel_compat.c rename to kernel/seccomp_cache.c index 6e0fe8ad..286b5ca3 100644 --- a/kernel/kernel_compat.c +++ b/kernel/seccomp_cache.c @@ -6,7 +6,7 @@ #include #include #include "klog.h" // IWYU pragma: keep -#include "kernel_compat.h" +#include "seccomp_cache.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 2) // Android backport this feature in 5.10.2 diff --git a/kernel/seccomp_cache.h b/kernel/seccomp_cache.h new file mode 100644 index 00000000..ce883289 --- /dev/null +++ b/kernel/seccomp_cache.h @@ -0,0 +1,12 @@ +#ifndef __KSU_H_SECCOMP_CACHE +#define __KSU_H_SECCOMP_CACHE + +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 2) // Android backport this feature in 5.10.2 +extern void ksu_seccomp_clear_cache(struct seccomp_filter *filter, int nr); +extern void ksu_seccomp_allow_cache(struct seccomp_filter *filter, int nr); +#endif + +#endif \ No newline at end of file diff --git a/kernel/selinux/sepolicy.c b/kernel/selinux/sepolicy.c index 8d128c1f..e31fc08c 100644 --- a/kernel/selinux/sepolicy.c +++ b/kernel/selinux/sepolicy.c @@ -6,7 +6,6 @@ #include "sepolicy.h" #include "../klog.h" // IWYU pragma: keep #include "ss/symtab.h" -#include "../kernel_compat.h" // Add check Huawei Device #define KSU_SUPPORT_ADD_TYPE diff --git a/kernel/sucompat.c b/kernel/sucompat.c index 56b0b810..1c69bdfa 100644 --- a/kernel/sucompat.c +++ b/kernel/sucompat.c @@ -24,7 +24,6 @@ #include "feature.h" #include "klog.h" // IWYU pragma: keep #include "ksud.h" -#include "kernel_compat.h" #include "sucompat.h" #include "core_hook.h" #include "sulog.h" diff --git a/kernel/sulog.c b/kernel/sulog.c index 8b7a28c3..00104952 100644 --- a/kernel/sulog.c +++ b/kernel/sulog.c @@ -15,7 +15,6 @@ #include #include "klog.h" -#include "kernel_compat.h" #include "sulog.h" #include "ksu.h" diff --git a/kernel/supercalls.c b/kernel/supercalls.c index 3dcade72..09e72e78 100644 --- a/kernel/supercalls.c +++ b/kernel/supercalls.c @@ -20,7 +20,6 @@ #include "core_hook.h" #include "objsec.h" #include "file_wrapper.h" -#include "kernel_compat.h" #include "throne_comm.h" #include "dynamic_manager.h" #include "umount_manager.h" diff --git a/kernel/throne_comm.c b/kernel/throne_comm.c index bb592051..90067dcc 100644 --- a/kernel/throne_comm.c +++ b/kernel/throne_comm.c @@ -7,7 +7,6 @@ #include "klog.h" #include "throne_comm.h" -#include "kernel_compat.h" #include "ksu.h" #define PROC_UID_SCANNER "ksu_uid_scanner" diff --git a/kernel/throne_tracker.c b/kernel/throne_tracker.c index 35ddc998..4abcf6dd 100644 --- a/kernel/throne_tracker.c +++ b/kernel/throne_tracker.c @@ -13,7 +13,6 @@ #include "ksu.h" #include "manager.h" #include "throne_tracker.h" -#include "kernel_compat.h" #include "apk_sign.h" #include "dynamic_manager.h" #include "throne_comm.h"