Linux kernel 如何在内核2.6中注册Linux安全模块?

Linux kernel 如何在内核2.6中注册Linux安全模块?,linux-kernel,linux-security-module,Linux Kernel,Linux Security Module,我想在内核ubuntu 2.6.36中使用LSM框架 当我编译内核模块时,它写道: 警告:注册\u安全未定义 经过多次搜索,我发现原因是2.6内核中不再导出register_安全符号 因此,我在../security/security.c文件中添加了EXPORT_SYMBOLregister_security,并重新编译了内核 使用新内核启动后,我在内核模块文件中添加了extern int register\u securitystruct security\u operations*ops,并

我想在内核ubuntu 2.6.36中使用LSM框架

当我编译内核模块时,它写道:

警告:注册\u安全未定义

经过多次搜索,我发现原因是2.6内核中不再导出register_安全符号

因此,我在../security/security.c文件中添加了EXPORT_SYMBOLregister_security,并重新编译了内核

使用新内核启动后,我在内核模块文件中添加了extern int register\u securitystruct security\u operations*ops,并再次编译了模块。 但是,警告信息仍然存在。如果我继续检查模块,dmesg会告诉我

未知符号寄存器\u安全性

我该怎么办?如何注册Linux安全模块

确保新加载的内核是由您编译的内核。 检查模块Ref的许可证:
在现代内核中,寄存器不导出安全符号。这意味着您不能将LSM模块注册为模块。但是如果你真的想这样做,你可以这样做:看看导出的LSM符号,比如安全性(security)\u sb\u copy\u数据。它们是安全操作->某些方法的简单包装。因此,您可以使用它们的代码来确定安全指针值。但它需要反汇编程序

Unknown symbol register_security
发生在你注销LSM的那一行。 因此,在security.c中添加unregister_security并将其导出:

 /**
 *  unregister_security - allows security modules to be moved
 * @ops : a pointer to the struct security_options that had been registered before.
 */
 int unregister_security(struct security_operations *ops)
{
        if (ops != security_ops) 
      {
                printk (KERN_INFO "%s: trying to unregister "
                        "a security_opts structure that is not "
                         "registered, failing.\n", __FUNCTION__);
                return -EINVAL;
         }
     security_ops = &dummy_security_ops;
      return 0;
}
 EXPORT_SYMBOL(unregister_security);
并重新编译内核