From a4b2d4286d5d3d6f4d2c895835a8134196875405 Mon Sep 17 00:00:00 2001 From: hmtheboy154 Date: Fri, 31 May 2024 02:45:29 -0400 Subject: [PATCH] kernelsu: LSM: Identify modules by more than name 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 --- kernel/core_hook.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 913867a579c1..452dfb34ed16 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -630,9 +630,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