Linux内核模块配置

标签 linux linux-kernel kernel-module

对于我的大学项目,我正在做一个模块,该模块将允许或禁止进程执行系统调用(例如,一个小的可加载 selinux)。现在我有控制系统调用的代码。对于每个进程,我都存储一个指向包含权限配置的结构的链接。但是,现在我只是硬编码了两个配置:一个是默认配置(允许所有配置),另一个是允许除打开“/testfile”之外的所有配置。

我的问题是如何动态加载配置?

我有一个配置文件的解析器,但我读到从内核访问文件是个坏主意。

我应该如何存储配置以及如何加载它们?

最佳答案

I've read that reading files from the kernel is bad idea

filp_open 的描述内核源代码中的函数说:

This is the helper to open a file from kernelspace if you really have to. But in generally you should not do this, so please move along, nothing to see here..

因此,如果您需要将文件内容加载到/从内核模块中存储,那么就去做。但是使用适当的功能,如所述in that question .

关于Linux内核模块配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34354113/

相关文章:

linux - 命令 "gcloud compute ssh"和 "ssh"之间的区别

linux-kernel - 如何在内核中分配不可缓存的物理内存?

c - 如何完全释放定时器(timer_list)?

linux - 如何编写 Linux .dts 设备树文件?

linux - 对于以下情况,如何编写一行 cd 命令?

linux - 存储由名称中带有空格的文件组成的 ls 命令的输出

java - 多线程降低了 NUMA 上的套接字吞吐量

在 Linux 中使用 makefile 编译内核模块

linux-kernel - 使用 perf userland 工具和 PEBS 进行基于事件的采样

linux - 如何停止 init_module : linux kernel