kernel: allow GKI kprobes to use LSM hook for ksu_handle_devpts

* Also minor changes on comments

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
This commit is contained in:
rsuntk
2025-06-19 21:33:52 +07:00
committed by ShirkNeko
parent ae475cba67
commit ea7e2f4db6
3 changed files with 15 additions and 13 deletions

View File

@@ -726,13 +726,8 @@ static int ksu_task_fix_setuid(struct cred *new, const struct cred *old,
return ksu_handle_setuid(new, old);
}
/*
* Keep in mind, since kprobes already have pre handler, we must
* guard it with CONFIG_KSU_KPROBES_HOOK, although it is possible to
* disable kprobes pre handler, but this is way more simple.
* However, if you wanna use LSM hooks, feel free to fork.
*/
#if !defined(KSU_HAS_DEVPTS_HANDLER) && !defined(CONFIG_KSU_KPROBES_HOOK)
#ifndef MODULE
#ifndef KSU_HAS_DEVPTS_HANDLER
extern int ksu_handle_devpts(struct inode *inode);
static int ksu_inode_permission(struct inode *inode, int mask)
{
@@ -746,12 +741,11 @@ static int ksu_inode_permission(struct inode *inode, int mask)
}
#endif
#ifndef MODULE
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),
#if !defined(KSU_HAS_DEVPTS_HANDLER) && !defined(CONFIG_KSU_KPROBES_HOOK)
#ifndef KSU_HAS_DEVPTS_HANDLER
LSM_HOOK_INIT(inode_permission, ksu_inode_permission),
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || \