kernel: phase out devpts_hook
* Since it's interceptable from LSM Hook, then we just need to remove ksu_handle_devpts and make a decoy for it. Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
This commit is contained in:
@@ -137,20 +137,6 @@ $(info -- KernelSU: SusFS: Adding 'int path_umount(struct path *path, int flags)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# we have pts_unix98/devpts_get_priv hook compat !!
|
|
||||||
KSU_HAS_DEVPTS_INODE := $(shell grep -q "ksu_handle_devpts" $(srctree)/fs/devpts/inode.c; echo $$?)
|
|
||||||
KSU_HAS_PTS_UNIX98 := $(shell grep -q "ksu_handle_devpts" $(srctree)/drivers/tty/pty.c; echo $$?)
|
|
||||||
|
|
||||||
# Codes:
|
|
||||||
# - 0: Both of them exist (impossible)
|
|
||||||
# - 1: Neither fs/devpts/inode.c or drivers/tty/pty.c have ksu_handle_devpts
|
|
||||||
# - 2: Both of them did not exist
|
|
||||||
$(eval KSU_DEVPTS_HANDLER_EXIST=$(shell expr $(KSU_HAS_DEVPTS_INODE) + $(KSU_HAS_PTS_UNIX98)))
|
|
||||||
ifeq ($(KSU_DEVPTS_HANDLER_EXIST),1)
|
|
||||||
$(info -- KernelSU: Kernel have devpts handler)
|
|
||||||
ccflags-y += -DKSU_HAS_DEVPTS_HANDLER
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Checks Samsung UH drivers
|
# Checks Samsung UH drivers
|
||||||
ifeq ($(shell grep -q "CONFIG_KDP_CRED" $(srctree)/kernel/cred.c; echo $$?),0)
|
ifeq ($(shell grep -q "CONFIG_KDP_CRED" $(srctree)/kernel/cred.c; echo $$?),0)
|
||||||
ccflags-y += -DSAMSUNG_UH_DRIVER_EXIST
|
ccflags-y += -DSAMSUNG_UH_DRIVER_EXIST
|
||||||
|
|||||||
@@ -1400,27 +1400,23 @@ static int ksu_task_fix_setuid(struct cred *new, const struct cred *old,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MODULE
|
#ifndef MODULE
|
||||||
#ifndef KSU_HAS_DEVPTS_HANDLER
|
extern int __ksu_handle_devpts(struct inode *inode);
|
||||||
extern int ksu_handle_devpts(struct inode *inode);
|
|
||||||
static int ksu_inode_permission(struct inode *inode, int mask)
|
static int ksu_inode_permission(struct inode *inode, int mask)
|
||||||
{
|
{
|
||||||
if (unlikely(inode->i_sb && inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC)) {
|
if (unlikely(inode->i_sb && inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC)) {
|
||||||
#ifdef CONFIG_KSU_DEBUG
|
#ifdef CONFIG_KSU_DEBUG
|
||||||
pr_info("%s: devpts inode accessed with mask: %x\n", __func__, mask);
|
pr_info("%s: devpts inode accessed with mask: %x\n", __func__, mask);
|
||||||
#endif
|
#endif
|
||||||
ksu_handle_devpts(inode);
|
__ksu_handle_devpts(inode);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct security_hook_list ksu_hooks[] = {
|
static struct security_hook_list ksu_hooks[] = {
|
||||||
LSM_HOOK_INIT(task_prctl, ksu_task_prctl),
|
LSM_HOOK_INIT(task_prctl, ksu_task_prctl),
|
||||||
LSM_HOOK_INIT(inode_rename, ksu_inode_rename),
|
LSM_HOOK_INIT(inode_rename, ksu_inode_rename),
|
||||||
LSM_HOOK_INIT(task_fix_setuid, ksu_task_fix_setuid),
|
LSM_HOOK_INIT(task_fix_setuid, ksu_task_fix_setuid),
|
||||||
#ifndef KSU_HAS_DEVPTS_HANDLER
|
|
||||||
LSM_HOOK_INIT(inode_permission, ksu_inode_permission),
|
LSM_HOOK_INIT(inode_permission, ksu_inode_permission),
|
||||||
#endif
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || \
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || \
|
||||||
defined(CONFIG_IS_HW_HISI) || \
|
defined(CONFIG_IS_HW_HISI) || \
|
||||||
defined(CONFIG_KSU_ALLOWLIST_WORKAROUND)
|
defined(CONFIG_KSU_ALLOWLIST_WORKAROUND)
|
||||||
|
|||||||
@@ -233,14 +233,8 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ksu_handle_devpts(struct inode *inode)
|
static int ksu_inline_handle_devpts(struct inode *inode)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_KSU_KPROBES_HOOK
|
|
||||||
if (!ksu_sucompat_hook_state) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!current->mm) {
|
if (!current->mm) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -269,6 +263,22 @@ int ksu_handle_devpts(struct inode *inode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __ksu_handle_devpts(struct inode *inode)
|
||||||
|
{
|
||||||
|
#ifndef CONFIG_KSU_KPROBES_HOOK
|
||||||
|
if (!ksu_sucompat_hook_state) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ksu_inline_handle_devpts(inode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dead code, we are phasing out ksu_handle_devpts for LSM hooks.
|
||||||
|
int __maybe_unused ksu_handle_devpts(struct inode *inode)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_KSU_KPROBES_HOOK
|
#ifdef CONFIG_KSU_KPROBES_HOOK
|
||||||
|
|
||||||
static int faccessat_handler_pre(struct kprobe *p, struct pt_regs *regs)
|
static int faccessat_handler_pre(struct kprobe *p, struct pt_regs *regs)
|
||||||
@@ -315,7 +325,7 @@ static int pts_unix98_lookup_pre(struct kprobe *p, struct pt_regs *regs)
|
|||||||
inode = (struct inode *)PT_REGS_PARM2(regs);
|
inode = (struct inode *)PT_REGS_PARM2(regs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ksu_handle_devpts(inode);
|
return ksu_inline_handle_devpts(inode);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static struct kprobe *su_kps[5];
|
static struct kprobe *su_kps[5];
|
||||||
|
|||||||
Reference in New Issue
Block a user