diff --git a/kernel/Kconfig b/kernel/Kconfig index 0831a362..904439bb 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -32,4 +32,12 @@ config KSU_ALLOWLIST_WORKAROUND Enable session keyring init workaround for problematic devices. Useful for situations where the SU allowlist is not kept after a reboot. +config KSU_LSM_SECURITY_HOOKS + bool "use lsm security hooks" + depends on KSU + default y + help + Disabling this is mostly only useful for kernel 4.1 and older. + Make sure to implement manual hooks on security/security.c. + endmenu diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 3677ca77..7ca786e3 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -7,7 +7,9 @@ #include #include #include +#ifdef CONFIG_KSU_LSM_SECURITY_HOOKS #include +#endif #include #include #include @@ -723,15 +725,9 @@ __maybe_unused int ksu_kprobe_exit(void) return 0; } -static int ksu_task_prctl(int option, unsigned long arg2, unsigned long arg3, - unsigned long arg4, unsigned long arg5) -{ - ksu_handle_prctl(option, arg2, arg3, arg4, arg5); - return -ENOSYS; -} -// kernel 4.4 and 4.9 +// kernel 4.9 and older #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || defined(CONFIG_IS_HW_HISI) || defined(CONFIG_KSU_ALLOWLIST_WORKAROUND) -static int ksu_key_permission(key_ref_t key_ref, const struct cred *cred, +int ksu_key_permission(key_ref_t key_ref, const struct cred *cred, unsigned perm) { if (init_session_keyring != NULL) { @@ -746,6 +742,15 @@ static int ksu_key_permission(key_ref_t key_ref, const struct cred *cred, return 0; } #endif + +#ifdef CONFIG_KSU_LSM_SECURITY_HOOKS +static int ksu_task_prctl(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + ksu_handle_prctl(option, arg2, arg3, arg4, arg5); + return -ENOSYS; +} + static int ksu_inode_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry) { @@ -959,3 +964,9 @@ void ksu_core_exit(void) // ksu_kprobe_exit(); #endif } +#else +void __init ksu_core_init(void) +{ + pr_info("ksu_core_init: LSM hooks not in use.\n"); +} +#endif //CONFIG_KSU_LSM_SECURITY_HOOKS