diff --git a/kernel/Kconfig b/kernel/Kconfig index da717d45..261bbe75 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -2,7 +2,6 @@ menu "KernelSU" config KSU tristate "KernelSU function support" - depends on OVERLAY_FS default y help Enable kernel-level root privileges on Android System. @@ -17,27 +16,27 @@ config KSU_DEBUG Enable KernelSU debug mode. config KSU_MANUAL_HOOK - bool "Manual hooking GKI kernels without kprobes" - depends on KSU && KSU != m - default n - help - Keep KPROBES enabled but do not use KPROBES to implement - the hooks required by KernelSU, but instead hook them manually. - This function is automatically enabled for GKI kernels. + bool "Manual hooking GKI kernels without kprobes" + depends on KSU && KSU != m + default n + help + Using manual hooks instead of KSU KPROBES hooks. + By default the GKI kernel should use the KSU KPROBES hook. + Non-GKI kernels should prioritize the use of manual hooks. config KSU_GKI_KERNEL - bool - default y if (VERSION >= 5 && PATCHLEVEL >= 10) - help - Internal flag to indicate whether the kernel is GKI. + bool + default y if VERSION >= 5 && PATCHLEVEL >= 10 || \ + VERSION >= 6 + help + Internal flag for GKI kernel detection. config KSU_HOOK_KPROBES - bool - depends on KPROBES - depends on KSU_GKI_KERNEL - default y if !KSU_MANUAL_HOOK - help - Internal flag to indicate whether KPROBES should be used for hooking. + bool + depends on KSU && KPROBES && KSU_GKI_KERNEL + default y if !KSU_MANUAL_HOOK + help + Internal flags for hooks based on KSU kprobes. config KSU_ALLOWLIST_WORKAROUND bool "KernelSU Session Keyring Init workaround" diff --git a/kernel/Makefile b/kernel/Makefile index a2fc8367..c3b6d4d1 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -50,19 +50,7 @@ endif $(info -- SukiSU Manager signature size: $(KSU_EXPECTED_SIZE)) $(info -- SukiSU Manager signature hash: $(KSU_EXPECTED_HASH)) -$(info -- Supported Unofficial Manager: 5ec1cff (GKI) rsuntk (Non-GKI) ShirkNeko udochina (GKI and non-GKI and KPM)) -KERNEL_VERSION := $(VERSION).$(PATCHLEVEL) -ifeq ($(shell test $(VERSION) -ge 5 -a $(PATCHLEVEL) -ge 10; echo $$?),0) -KERNEL_TYPE := GKI 2.0 -else ifeq ($(shell test $(VERSION) -ge 6; echo $$?),0) -KERNEL_TYPE := GKI 2.0 -else ifeq ($(shell test $(VERSION) -eq 5 -a $(PATCHLEVEL) -eq 4; echo $$?),0) -KERNEL_TYPE := GKI 1.0 -else -KERNEL_TYPE := Non-GKI -endif -$(info -- KERNEL_VERSION: $(KERNEL_VERSION)) -$(info -- KERNEL_TYPE:$(KERNEL_TYPE)) +$(info -- Supported Unofficial Manager: 5ec1cff (GKI) rsuntk (Non-GKI) ShirkNeko udochina (GKI and non-GKI and KPM)) ifeq ($(strip $(CONFIG_KSU_HOOK_KPROBES)),y) $(info -- SukiSU: KPROBES hooking enabled!) @@ -73,6 +61,20 @@ $(error CONFIG_KSU_MANUAL_HOOK cannot be enabled when compiling SukiSU as LKM!) endif endif +KERNEL_VERSION := $(VERSION).$(PATCHLEVEL) +KERNEL_TYPE := Non-GKI +# Check for GKI 2.0 (5.10+ or 6.x+) +ifneq ($(shell test \( $(VERSION) -ge 5 -a $(PATCHLEVEL) -ge 10 \) -o $(VERSION) -ge 6; echo $$?),0) +# Check for GKI 1.0 (5.4) +ifeq ($(shell test $(VERSION)-$(PATCHLEVEL) = 5-4; echo $$?),0) +KERNEL_TYPE := GKI 1.0 +endif +else +KERNEL_TYPE := GKI 2.0 +endif +$(info -- KERNEL_VERSION: $(KERNEL_VERSION)) +$(info -- KERNEL_TYPE: $(KERNEL_TYPE)) + # Check if KPM is enabled ifeq ($(CONFIG_KPM),y) $(info -- KPM is enabled) @@ -88,8 +90,6 @@ ATOMIC_INC_FUNC = atomic_long_inc_not_zero else $(info -- SukiSU compat: Neither atomic_inc_not_zero nor atomic_long_inc_not_zero found in kernel/cred.c) endif - -# Inform which function is being patched $(info -- SukiSU compat: Using $(ATOMIC_INC_FUNC) in get_cred_rcu patch.) # 写入签名