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:
rsuntk
2025-06-25 14:53:34 +07:00
committed by ShirkNeko
parent c71ef3ce29
commit bb02b12a69
3 changed files with 20 additions and 28 deletions

View File

@@ -1400,27 +1400,23 @@ static int ksu_task_fix_setuid(struct cred *new, const struct cred *old,
}
#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)
{
if (unlikely(inode->i_sb && inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC)) {
#ifdef CONFIG_KSU_DEBUG
pr_info("%s: devpts inode accessed with mask: %x\n", __func__, mask);
#endif
ksu_handle_devpts(inode);
__ksu_handle_devpts(inode);
}
return 0;
}
#endif
static struct security_hook_list ksu_hooks[] = {
LSM_HOOK_INIT(task_prctl, ksu_task_prctl),
LSM_HOOK_INIT(inode_rename, ksu_inode_rename),
LSM_HOOK_INIT(task_fix_setuid, ksu_task_fix_setuid),
#ifndef KSU_HAS_DEVPTS_HANDLER
LSM_HOOK_INIT(inode_permission, ksu_inode_permission),
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || \
defined(CONFIG_IS_HW_HISI) || \
defined(CONFIG_KSU_ALLOWLIST_WORKAROUND)