How to select an executable page in a Linux kernel module?

I am writing a Linux kernel module and I would like to highlight an executable page. Plain kmalloc returns a pointer inside a non-executable page, and I get a kernel panic when I execute the code there. It should work on Ubuntu Karmic x86, 2.6.31-20-generic-pae.

+6
linux-kernel executable nx
source share
1 answer
#include <linux/vmalloc.h> #include <asm/pgtype_types.h> ... char *p = __vmalloc(byte_size, GFP_KERNEL, PAGE_KERNEL_EXEC); ... if (p != NULL) vfree(p); 
+8
source share

All Articles