From 71bb5a3d3bda3a5e19bd6032bf5e6af9ba2cba04 Mon Sep 17 00:00:00 2001 From: rsuntk <90097027+rsuntk@users.noreply.github.com> Date: Tue, 10 Jun 2025 17:21:12 +0000 Subject: [PATCH] kernel: kernel_compat: Remove inline get_cred_rcu Since commit: kernel: core_hook: switch to prepare_creds (c58e102) get_cred_rcu is no longer needed. Signed-off-by: rsuntk <90097027+rsuntk@users.noreply.github.com> --- kernel/Makefile | 12 ------------ kernel/kernel_compat.h | 21 --------------------- 2 files changed, 33 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index dbfb6a9f..f4f226f6 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -48,18 +48,6 @@ ifeq ($(shell grep -q "struct selinux_state " $(srctree)/security/selinux/includ ccflags-y += -DKSU_COMPAT_HAS_SELINUX_STATE endif -# This feature was introduced in linux 5.0-rc1 -ifeq ($(shell grep -q "get_cred_rcu" $(srctree)/include/linux/cred.h; echo $$?),0) -ccflags-y += -DKSU_COMPAT_HAS_GET_CRED_RCU -else -ifeq ($(shell grep -q "atomic_long_t\s\+usage" $(srctree)/include/linux/cred.h; echo $$?),0) -ccflags-y += -DKSU_COMPAT_ATOMIC_LONG -endif -ifeq ($(shell grep -q "int\s\+non_rcu" $(srctree)/include/linux/cred.h; echo $$?),0) -ccflags-y += -DKSU_COMPAT_HAS_NONCONST_CRED -endif -endif - # Handle optional backports ifeq ($(shell grep -q "strncpy_from_user_nofault" $(srctree)/include/linux/uaccess.h; echo $$?),0) ccflags-y += -DKSU_OPTIONAL_STRNCPY diff --git a/kernel/kernel_compat.h b/kernel/kernel_compat.h index ef6d22b9..df3edab2 100644 --- a/kernel/kernel_compat.h +++ b/kernel/kernel_compat.h @@ -7,27 +7,6 @@ #include "ss/policydb.h" #include "linux/key.h" -// for kernel without get_cred_rcu -#ifndef KSU_COMPAT_HAS_GET_CRED_RCU -static inline const struct cred *get_cred_rcu(const struct cred *cred) -{ - struct cred *nonconst_cred = (struct cred *) cred; - if (!cred) - return NULL; -#ifdef KSU_COMPAT_ATOMIC_LONG - if (!atomic_long_inc_not_zero(&nonconst_cred->usage)) -#else - if (!atomic_inc_not_zero(&nonconst_cred->usage)) -#endif - return NULL; - validate_creds(cred); -#ifdef KSU_COMPAT_HAS_NONCONST_CRED - nonconst_cred->non_rcu = 0; -#endif - return cred; -} -#endif - /* * Adapt to Huawei HISI kernel without affecting other kernels , * Huawei Hisi Kernel EBITMAP Enable or Disable Flag ,