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 4502a52e1b
commit 103217755b
3 changed files with 15 additions and 13 deletions

View File

@@ -303,6 +303,8 @@ static int execve_handler_pre(struct kprobe *p, struct pt_regs *regs)
NULL);
}
#ifdef MODULE
static struct kprobe *su_kps[6];
static int pts_unix98_lookup_pre(struct kprobe *p, struct pt_regs *regs)
{
struct inode *inode;
@@ -315,6 +317,9 @@ static int pts_unix98_lookup_pre(struct kprobe *p, struct pt_regs *regs)
return ksu_handle_devpts(inode);
}
#else
static struct kprobe *su_kps[5];
#endif
static struct kprobe *init_kprobe(const char *name,
kprobe_pre_handler_t handler)
@@ -345,8 +350,6 @@ static void destroy_kprobe(struct kprobe **kp_ptr)
kfree(kp);
*kp_ptr = NULL;
}
static struct kprobe *su_kps[6];
#endif
// sucompat: permited process can execute 'su' to gain root access.
@@ -358,7 +361,9 @@ void ksu_sucompat_init()
su_kps[2] = init_kprobe(SYS_FACCESSAT_SYMBOL, faccessat_handler_pre);
su_kps[3] = init_kprobe(SYS_NEWFSTATAT_SYMBOL, newfstatat_handler_pre);
su_kps[4] = init_kprobe(SYS_FSTATAT64_SYMBOL, newfstatat_handler_pre);
#ifdef MODULE
su_kps[5] = init_kprobe("pts_unix98_lookup", pts_unix98_lookup_pre);
#endif
#else
ksu_sucompat_hook_state = true;
pr_info("ksu_sucompat init\n");