2010-11-13 73 views
1

我想在内核ubuntu 2.6.36上使用LSM框架。如何在内核2.6中注册Linux安全模块?

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

警告: “register_security” 不确定!

经过大量的googlings之后,我发现原因是register_security()符号不再在2.6内核中输出。

因此,我在../security/security.c文件中添加了EXPORT_SYMBOL(register_security),并重新编译了内核。

在使用新内核启动后,我在内核模块文件中添加了extern int register_security(struct security_operations *ops),然后再次编译模块。 但是,WARNING信息依然存在。如果我继续insmode模块时,dmesg告诉我,

未知符号register_security

我应该怎么办?我怎样才能注册一个LSM模块?

非常感谢!

此致敬礼!

F.张

回答

0

在现代的内核register_security符号不出口。这意味着您不能将LSM模块注册为模块。但如果你真的希望这样做,你可以这样做:)看看导出的LSM符号,如security_sb_copy_data。它们是security_ops->some_lsm_method的简单包装。因此,您可以使用他们的代码来确定security_ops指针值。它需要反汇编。

0
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); 

并重新编译内核。