kernel: fix anon_get_inode_* compat

* Yes, we don't have fancy secure fd thing on older kernels.

Signed-off-by: Faris <rissu.ntk@gmail.com>
This commit is contained in:
Faris
2025-11-08 18:13:01 +07:00
committed by ShirkNeko
parent cc0dfc44ac
commit a473707c10
2 changed files with 11 additions and 2 deletions

View File

@@ -124,6 +124,10 @@ ifeq ($(shell grep -q "__poll_t" $(srctree)/include/linux/poll.h; echo $$?),1)
ccflags-y += -DKSU_NEED_POLL_T_DEF
endif
ifeq ($(shell grep -q "anon_inode_getfd_secure" $(srctree)/fs/anon_inodes.c; echo $$?),0)
ccflags-y += -DKSU_HAS_GETFD_SECURE
endif
# Checks Samsung
ifeq ($(shell grep -q "CONFIG_KDP_CRED" $(srctree)/kernel/cred.c; echo $$?),0)
ccflags-y += -DSAMSUNG_UH_DRIVER_EXIST

View File

@@ -381,17 +381,22 @@ static int __do_get_wrapper_fd(void __user *arg, const char *anon_name)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
#define getfd_secure anon_inode_create_getfd
#else
#elif defined(KSU_HAS_GETFD_SECURE)
#define getfd_secure anon_inode_getfd_secure
#endif
#ifdef KSU_HAS_GETFD_SECURE
ret = getfd_secure(anon_name, &data->ops, data, f->f_flags, NULL);
#else
ret = anon_inode_getfd(anon_name, &data->ops, data, f->f_flags);
#endif
if (ret < 0) {
pr_err("ksu_fdwrapper: getfd failed: %d\n", ret);
goto put_wrapper_data;
}
struct file *pf = fget(ret);
struct file *pf = fget(ret);
struct inode *wrapper_inode = file_inode(pf);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) || \
defined(KSU_OPTIONAL_SELINUX_INODE)