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.
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.
My kernel module will be a loadable module, so internal symbols are not available to me.
Thanks, in advance, for your guidance.
__do_sysmprotect
is a static function. Not sure if it can be called in modules. – Ponceau