Module Name: src
Committed By: maxv
Date: Wed Aug 29 06:17:26 UTC 2018
Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c
Log Message:
Simplify the ASLR stuff, we don't care about resizable areas now, and it
makes the code more complicated for no good reason.
To generate a diff of this commit:
cvs rdiff -u -r1.316 -r1.317 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.305 -r1.306 src/sys/arch/x86/x86/pmap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.316 src/sys/arch/amd64/amd64/machdep.c:1.317
--- src/sys/arch/amd64/amd64/machdep.c:1.316 Wed Aug 22 12:07:42 2018
+++ src/sys/arch/amd64/amd64/machdep.c Wed Aug 29 06:17:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.316 2018/08/22 12:07:42 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.317 2018/08/29 06:17:26 maxv Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.316 2018/08/22 12:07:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.317 2018/08/29 06:17:26 maxv Exp $");
#include "opt_modular.h"
#include "opt_user_ldt.h"
@@ -1617,75 +1617,55 @@ init_slotspace(void)
/* User. [256, because we want to land in >= 256] */
slotspace.area[SLAREA_USER].sslot = 0;
- slotspace.area[SLAREA_USER].mslot = PDIR_SLOT_USERLIM+1;
slotspace.area[SLAREA_USER].nslot = PDIR_SLOT_USERLIM+1;
slotspace.area[SLAREA_USER].active = true;
- slotspace.area[SLAREA_USER].dropmax = false;
#ifdef XEN
/* PTE. */
slotspace.area[SLAREA_PTE].sslot = PDIR_SLOT_PTE;
- slotspace.area[SLAREA_PTE].mslot = 1;
slotspace.area[SLAREA_PTE].nslot = 1;
slotspace.area[SLAREA_PTE].active = true;
- slotspace.area[SLAREA_PTE].dropmax = false;
#endif
#ifdef __HAVE_PCPU_AREA
/* Per-CPU. */
slotspace.area[SLAREA_PCPU].sslot = PDIR_SLOT_PCPU;
- slotspace.area[SLAREA_PCPU].mslot = 1;
slotspace.area[SLAREA_PCPU].nslot = 1;
slotspace.area[SLAREA_PCPU].active = true;
- slotspace.area[SLAREA_PCPU].dropmax = false;
#endif
#ifdef __HAVE_DIRECT_MAP
- /* Direct Map. */
- slotspace.area[SLAREA_DMAP].sslot = PDIR_SLOT_DIRECT;
- slotspace.area[SLAREA_DMAP].mslot = NL4_SLOT_DIRECT+1;
- slotspace.area[SLAREA_DMAP].nslot = 0 /* variable */;
+ /* Direct Map. [Randomized later] */
slotspace.area[SLAREA_DMAP].active = false;
- slotspace.area[SLAREA_DMAP].dropmax = true;
#endif
#ifdef XEN
/* Hypervisor. */
slotspace.area[SLAREA_HYPV].sslot = 256;
- slotspace.area[SLAREA_HYPV].mslot = 17;
slotspace.area[SLAREA_HYPV].nslot = 17;
slotspace.area[SLAREA_HYPV].active = true;
- slotspace.area[SLAREA_HYPV].dropmax = false;
#endif
#ifdef KASAN
/* ASAN. */
slotspace.area[SLAREA_ASAN].sslot = L4_SLOT_KASAN;
- slotspace.area[SLAREA_ASAN].mslot = NL4_SLOT_KASAN;
slotspace.area[SLAREA_ASAN].nslot = NL4_SLOT_KASAN;
slotspace.area[SLAREA_ASAN].active = true;
- slotspace.area[SLAREA_ASAN].dropmax = false;
#endif
/* Kernel. */
slotspace.area[SLAREA_KERN].sslot = L4_SLOT_KERNBASE;
- slotspace.area[SLAREA_KERN].mslot = 1;
slotspace.area[SLAREA_KERN].nslot = 1;
slotspace.area[SLAREA_KERN].active = true;
- slotspace.area[SLAREA_KERN].dropmax = false;
/* Main. */
- slotspace.area[SLAREA_MAIN].mslot = NKL4_MAX_ENTRIES+1;
- slotspace.area[SLAREA_MAIN].dropmax = false;
va = slotspace_rand(SLAREA_MAIN, NKL4_MAX_ENTRIES * NBPD_L4,
- NBPD_L4);
+ NBPD_L4); /* TODO: NBPD_L1 */
vm_min_kernel_address = va;
vm_max_kernel_address = va + NKL4_MAX_ENTRIES * NBPD_L4;
#ifndef XEN
/* PTE. */
- slotspace.area[SLAREA_PTE].mslot = 1;
- slotspace.area[SLAREA_PTE].dropmax = false;
va = slotspace_rand(SLAREA_PTE, NBPD_L4, NBPD_L4);
pte_base = (pd_entry_t *)va;
#endif
Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.85 src/sys/arch/x86/include/pmap.h:1.86
--- src/sys/arch/x86/include/pmap.h:1.85 Mon Aug 20 15:04:52 2018
+++ src/sys/arch/x86/include/pmap.h Wed Aug 29 06:17:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.85 2018/08/20 15:04:52 maxv Exp $ */
+/* $NetBSD: pmap.h,v 1.86 2018/08/29 06:17:26 maxv Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -169,9 +169,7 @@ struct slotspace {
struct {
size_t sslot; /* start slot */
size_t nslot; /* # of slots */
- size_t mslot; /* max # of slots */
bool active; /* area is active */
- bool dropmax; /* !resizable */
} area[SLSPACE_NAREAS];
};
Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.305 src/sys/arch/x86/x86/pmap.c:1.306
--- src/sys/arch/x86/x86/pmap.c:1.305 Wed Aug 22 12:07:43 2018
+++ src/sys/arch/x86/x86/pmap.c Wed Aug 29 06:17:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.305 2018/08/22 12:07:43 maxv Exp $ */
+/* $NetBSD: pmap.c,v 1.306 2018/08/29 06:17:26 maxv Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -157,7 +157,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.305 2018/08/22 12:07:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.306 2018/08/29 06:17:26 maxv Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1473,9 +1473,6 @@ slotspace_rand(int type, size_t sz, size
slotspace.area[type].sslot = pl4_i(va);
slotspace.area[type].nslot =
pmap_pagetree_nentries_range(va, va+sz, NBPD_L4);
- if (slotspace.area[type].dropmax) {
- slotspace.area[type].mslot = slotspace.area[type].nslot;
- }
slotspace.area[type].active = true;
return va;