mprotect()类似于Linux内核中的功能

时间:2022-11-16 09:33:48

I am in a Linux kernel module, and I allocate some memory with, say, vmalloc(). I want to make the memory have read, write, and execute permission. What is the clean and appropriate way of doing that? Basically, this is generally the equivalent of calling mprotect(), but in kernel space.

我在Linux内核模块中,我用vmalloc()分配了一些内存。我想让内存具有读,写和执行权限。干净,适当的方式是什么?基本上,这通常相当于调用mprotect(),但在内核空间中。

If I do the page walk, pgd_offset(), pud_offset(), pmd_offset(), pte_offset_map(), and then pte_mkwrite(), I run into linking errors when I tried it on 2.6.39. Also, it seems that if I am doing the page walk, it is a hack, and there ought to be a cleaner and more appropriate method.

如果我执行页面遍历,pgd_offset(),pud_offset(),pmd_offset(),pte_offset_map(),然后是pte_mkwrite(),我在2.6.39上尝试时会遇到链接错误。此外,似乎如果我正在进行页面漫步,它是一个黑客,并且应该有一个更清洁,更合适的方法。

My kernel module will be a loadable module, so internal symbols are not available to me.

我的内核模块将是一个可加载模块,因此我无法使用内部符号。

Thanks, in advance, for your guidance.

在此先感谢您的指导。

1 个解决方案

#1


0  

Have you tried by invoking do_mprotect() [kernel function corresponding to mprotect()] directly ?

您是否尝试过直接调用do_mprotect()[对应于mprotect()的内核函数?

#1


0  

Have you tried by invoking do_mprotect() [kernel function corresponding to mprotect()] directly ?

您是否尝试过直接调用do_mprotect()[对应于mprotect()的内核函数?