使用LSM做一个系统的钩子,是我在本科毕设的核心。具体的代码已经没有了,但是这个LSM的demo可以帮助初步的配置,之后的代码实现主要依赖于LSM提供的钩子,并且需要对task_struct
和inode_struct
有一定的理解。
/*
* Test Linux Security Module
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
*/
#include <linux/security.h>
#include <linux/sysctl.h>
#include <linux/ptrace.h>
#include <linux/prctl.h>
#include <linux/ratelimit.h>
#include <linux/workqueue.h>
#include <linux/file.h>