Skip to content

Commit

Permalink
kernelsu: LSM: Identify modules by more than name
Browse files Browse the repository at this point in the history
This is based on commit "LSM: Identify modules by more than name"
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.8&id=f3b8788cde61b02f1e6c202f8fac4360e6adbafc

Which is a requirement to build on kernel 6.8+. I use 912 as the ID
for KernelSU as that's the date the Github repo was created.

Signed-off-by: hmtheboy154 <[email protected]>
  • Loading branch information
hmtheboy154 committed Jun 1, 2024
1 parent 898e9d4 commit 202e5e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,21 @@ static struct security_hook_list ksu_hooks[] = {
LSM_HOOK_INIT(task_fix_setuid, ksu_task_fix_setuid),
};

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
const struct lsm_id ksu_lsmid = {
.name = "ksu",
.id = 912,
};
#endif

void __init ksu_lsm_hook_init(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
// https://elixir.bootlin.com/linux/v6.8/source/include/linux/lsm_hooks.h#L120
security_add_hooks(ksu_hooks, ARRAY_SIZE(ksu_hooks), &ksu_lsmid);
#else
security_add_hooks(ksu_hooks, ARRAY_SIZE(ksu_hooks), "ksu");
#endif
}

#else
Expand Down

0 comments on commit 202e5e8

Please sign in to comment.