Skip to content

Commit

Permalink
Added ability to vmalloc executable memory
Browse files Browse the repository at this point in the history
Since release 5.8-rc1 the pgprot got removed from __vmalloc
because the only usage was PAGE_KERNEL as argument.
However, this removes the ability to input other arguments
such as 'PAGE_KERNEL_EXEC', which can be used to allocate
memory in which you can execute. For this reason a new
function is introduced called '__vmalloc_exec'.

Signed-off-by: Xander Moerkerken <xander.moerkerken@omron.com>
  • Loading branch information
Xander Moerkerken authored and intel-lab-lkp committed Dec 9, 2022
1 parent 0385eb4 commit 86c4449
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/vmalloc.h
Expand Up @@ -147,6 +147,7 @@ extern void *vzalloc_node(unsigned long size, int node) __alloc_size(1);
extern void *vmalloc_32(unsigned long size) __alloc_size(1);
extern void *vmalloc_32_user(unsigned long size) __alloc_size(1);
extern void *__vmalloc(unsigned long size, gfp_t gfp_mask) __alloc_size(1);
extern void *__vmalloc_exec(unsigned long size, gfp_t gfp_mask) __alloc_size(1);
extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
unsigned long start, unsigned long end, gfp_t gfp_mask,
pgprot_t prot, unsigned long vm_flags, int node,
Expand Down
8 changes: 8 additions & 0 deletions mm/vmalloc.c
Expand Up @@ -3308,6 +3308,14 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask)
}
EXPORT_SYMBOL(__vmalloc);


void *__vmalloc_exec(unsigned long size, gfp_t gfp_mask)
{
return __vmalloc_node_prot(size, 1, gfp_mask, PAGE_KERNEL_EXEC,
NUMA_NO_NODE, __builtin_return_address(0));
}
EXPORT_SYMBOL(__vmalloc_exec);

/**
* vmalloc - allocate virtually contiguous memory
* @size: allocation size
Expand Down

0 comments on commit 86c4449

Please sign in to comment.