gpt4 book ai didi

linux - 错误 register_security undefined

转载 作者:太空宇宙 更新时间:2023-11-04 09:37:00 25 4
gpt4 key购买 nike

我正在内核版本 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");

输出:

register_security 未定义

我不知道为什么显示 register_security not defined ?关于如何使用 register_security 的任何建议。注意:我不想编辑现有的内核头文件,如 security.h

最佳答案

register_security() 不是从内核导出的(即没有 EXPORT_SYMBOL(register_security))。也就是说,register_security() 只能在内核内部被引用;你不能从模块访问它。

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

关于linux - 错误 register_security undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25589364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com