Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 错误寄存器\u未定义安全性_Linux_Security_Linux Kernel_Kernel_Kernel Module - Fatal编程技术网

Linux 错误寄存器\u未定义安全性

Linux 错误寄存器\u未定义安全性,linux,security,linux-kernel,kernel,kernel-module,Linux,Security,Linux Kernel,Kernel,Kernel Module,我正在内核版本3.14.17中编写一个简单的LSM代码 代码段: #include <linux/module.h> // included for all kernel modules #include <linux/kernel.h> // included for KERN_INFO #include <linux/init.h> // included for __init and __exit macros #include &

我正在内核版本3.14.17中编写一个简单的LSM代码

代码段:

#include <linux/module.h>    // included for all kernel modules
#include <linux/kernel.h>    // included for KERN_INFO
#include <linux/init.h>      // included for __init and __exit macros
#include <linux/security.h>
#include <linux/tracehook.h>


static int blabbermouth_inode_alloc_security(struct inode *inode)
{
    return 0;
}

static void blabbermouth_inode_free_security(struct inode *inode)
{
}

static struct security_operations blabbermouth_ops = {
    .inode_alloc_security =     blabbermouth_inode_alloc_security,
    .inode_free_security =      blabbermouth_inode_free_security,
};



static int __init hello_init(void)
{
    if (register_security(&blabbermouth_ops))
        panic("blabbermouth: Unable to register blabbermouth with kernel.\n");
    else 
        printk("blabbermouth: registered with the kernel\n");

    return 0;
}

static void __exit hello_cleanup(void)
{
    printk("Exit \n");
    return;
}

module_init(hello_init);
module_exit(hello_cleanup);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
#include//包含在所有内核模块中
#include//include for KERN_INFO
#include//include for _init和_exit宏
#包括
#包括
静态int blabbermouth_inode_alloc_安全性(struct inode*inode)
{
返回0;
}
静态void blabbermouth_inode_free_安全性(结构inode*inode)
{
}
静态结构安全操作blabbermouth操作={
.inode_alloc_security=blabbermouth_inode_alloc_security,
.inode_free_security=blabbermouth_inode_free_security,
};
静态int\uu init hello\u init(void)
{
if(注册安全和blabbermouth操作)
死机(“blabbermouth:无法向内核注册blabbermouth。\n”);
其他的
printk(“blabbermouth:registeredthekernel\n”);
返回0;
}
静态void\uu退出hello\u清理(void)
{
printk(“退出”);
返回;
}
模块_init(hello_init);
模块退出(hello\u清理);
模块许可证(“GPL”);
模块作者(“拉克希曼南”);
模块描述(“一个简单的Hello World模块”);
输出:

寄存器\u安全性未定义

我不知道为什么它会显示未定义的注册表_安全性? 任何关于如何使用注册表安全性的建议。 注意:我不想编辑现有的内核头,比如security.h

register\u security()
不是从内核导出的(即没有
EXPORT\u符号(register\u security)
)。这意味着,
register\u security()
只能在内核内部引用;您无法从模块访问它


此外,
register\u security()
被定义为
\u init
。这意味着,只要初始化过程完成,内核就可以删除此符号。

似乎LSM已烘焙到内核中,您无法对其进行热交换。换句话说,你不能只为它写一个模块。