lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  9 Dec 2022 14:10:52 +0100
From:   Xander Moerkerken <xandermoerkerken@...il.com>
To:     akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Xander Moerkerken <xander.moerkerken@...il.com>,
        Xander Moerkerken <xander.moerkerken@...on.com>
Subject: [PATCH] Added ability to vmalloc executable memory

From: Xander Moerkerken <xander.moerkerken@...il.com>

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@...on.com>
---
 include/linux/vmalloc.h | 1 +
 mm/vmalloc.c            | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 096d48aa3437..10c46513b6b2 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -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,
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ccaa461998f3..8fd01ed7082b 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3294,6 +3294,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
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ