|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 5/5] x86/pvh: Enable memory KASLR
PVH guests boot the uncompressed kernel directly, so nothing sets
KASLR_FLAG and memory randomization is never enabled, although the
regular setup_arch() path is used and works fine with it.
Set KASLR_FLAG in init_pvh_bootparams() unless "nokaslr" is passed on
the command line.
Tested as PVH domU (1G and 16G) with upstream Xen, with and without
"nokaslr".
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
Assisted-by: LLM
---
CC: Juergen Gross <jgross@xxxxxxxx>
CC: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
arch/x86/platform/pvh/enlighten.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/platform/pvh/enlighten.c
b/arch/x86/platform/pvh/enlighten.c
index 88632c661430..41057d42c92a 100644
--- a/arch/x86/platform/pvh/enlighten.c
+++ b/arch/x86/platform/pvh/enlighten.c
@@ -4,6 +4,7 @@
#include <xen/hvc-console.h>
#include <asm/bootparam.h>
+#include <asm/cmdline.h>
#include <asm/io_apic.h>
#include <asm/hypervisor.h>
#include <asm/e820/api.h>
@@ -74,6 +75,16 @@ static void __init init_pvh_bootparams(bool xen_guest)
pvh_bootparams.hdr.cmd_line_ptr =
pvh_start_info.cmdline_paddr;
+ /*
+ * There is no decompressor to handle "nokaslr" and set KASLR_FLAG,
+ * do it here so that memory randomization is enabled.
+ */
+ if (IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
+ !(pvh_start_info.cmdline_paddr &&
+ cmdline_find_option_bool(__va(pvh_start_info.cmdline_paddr),
+ "nokaslr")))
+ pvh_bootparams.hdr.loadflags |= KASLR_FLAG;
+
/* The first module is always ramdisk. */
if (pvh_start_info.nr_modules) {
struct hvm_modlist_entry *modaddr =
--
2.56.1
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |