Reputation: 309
I am currently writing a kernel module for Linux and been trying to dynamically allocate a large block of memory and changing its permissions (rwx), but it just won't work.
do_mmap
and init_mm
seem to be missing (recognized as undefined by the linker).
A possible solution might be accessing the kernel's vma but I couldn't find a way to access it.
Is it possible to change permissions of heap in kernel space?
Upvotes: 0
Views: 1026
Reputation: 137438
vmalloc_exec
is not exported for driver use, so you cannot use it.
However, __vmalloc
takes a page protections argument, so it should do what you want:
void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
So to allocate executable pages, try this:
void *p = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL_EXEC);
Upvotes: 2