41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#include <linux/err.h>
|
|
#include <linux/cred.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/printk.h>
|
|
#include <linux/security.h>
|
|
#include <linux/lsm_hooks.h>
|
|
#include <linux/module.h>
|
|
#include <linux/version.h>
|
|
|
|
#include "klog.h"
|
|
#include "ksu.h"
|
|
|
|
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)
|
|
{
|
|
return ksu_handle_rename(old_dentry, new_dentry);
|
|
}
|
|
|
|
static struct security_hook_list ksu_hooks[] = {
|
|
LSM_HOOK_INIT(task_prctl, ksu_task_prctl),
|
|
LSM_HOOK_INIT(inode_rename, ksu_inode_rename),
|
|
};
|
|
|
|
void __init ksu_lsm_hook_init(void)
|
|
{
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
|
security_add_hooks(ksu_hooks, ARRAY_SIZE(ksu_hooks), "ksu");
|
|
#else
|
|
// https://elixir.bootlin.com/linux/v4.10.17/source/include/linux/lsm_hooks.h#L1892
|
|
security_add_hooks(ksu_hooks, ARRAY_SIZE(ksu_hooks));
|
|
#endif
|
|
|
|
pr_info("security_add_hooks\n");
|
|
} |