Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 Add an option to have a static kernel memory la...
details: https://anonhg.NetBSD.org/src/rev/fa0e3d465d33
branches: trunk
changeset: 995107:fa0e3d465d33
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Dec 07 15:47:11 2018 +0000
description:
Add an option to have a static kernel memory layout. This option is
disabled by default - that is to say, KASLR remains enabled by default.
diffstat:
sys/arch/x86/conf/files.x86 | 5 ++++-
sys/arch/x86/x86/pmap.c | 11 +++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diffs (65 lines):
diff -r a0c16c6a0b25 -r fa0e3d465d33 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86 Fri Dec 07 14:59:19 2018 +0000
+++ b/sys/arch/x86/conf/files.x86 Fri Dec 07 15:47:11 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.x86,v 1.103 2018/07/16 06:18:31 maxv Exp $
+# $NetBSD: files.x86,v 1.104 2018/12/07 15:47:11 maxv Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -17,6 +17,9 @@
# To be able to test for NetBSD/xen in shared files
defflag opt_xen.h DO_NOT_DEFINE
+# Option to have a static kernel memory layout
+defflag opt_kaslr.h NO_X86_ASLR
+
defflag SVS
define cpubus { [apid = -1] }
diff -r a0c16c6a0b25 -r fa0e3d465d33 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Fri Dec 07 14:59:19 2018 +0000
+++ b/sys/arch/x86/x86/pmap.c Fri Dec 07 15:47:11 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.312 2018/11/19 20:44:51 maxv Exp $ */
+/* $NetBSD: pmap.c,v 1.313 2018/12/07 15:47:11 maxv Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.312 2018/11/19 20:44:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.313 2018/12/07 15:47:11 maxv Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -138,6 +138,7 @@
#include "opt_xen.h"
#include "opt_svs.h"
#include "opt_kasan.h"
+#include "opt_kaslr.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -1360,6 +1361,9 @@
/* Select a hole. */
cpu_earlyrng(&hole, sizeof(hole));
+#ifdef NO_X86_ASLR
+ hole = 0;
+#endif
hole %= nholes;
startsl = holes[hole].start;
endsl = holes[hole].end;
@@ -1367,6 +1371,9 @@
/* Select an area within the hole. */
cpu_earlyrng(&va, sizeof(va));
+#ifdef NO_X86_ASLR
+ va = 0;
+#endif
winsize = ((endsl - startsl) * NBPD_L4) - sz;
va %= winsize;
va = rounddown(va, align);
Home |
Main Index |
Thread Index |
Old Index