Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Split the PRELOADED_MODULES+BOOTSTRAP_TABLES chunk ...



details:   https://anonhg.NetBSD.org/src/rev/1510a55ff27e
branches:  trunk
changeset: 345256:1510a55ff27e
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun May 15 07:17:53 2016 +0000

description:
Split the PRELOADED_MODULES+BOOTSTRAP_TABLES chunk into two separate
chunks mapped independently with RWX and RW, on both amd64 and i386.

This way the BOOTSTRAP TABLES are non-executable.

diffstat:

 sys/arch/amd64/amd64/locore.S |  21 ++++++++++-----------
 sys/arch/i386/i386/locore.S   |  23 +++++++++++------------
 2 files changed, 21 insertions(+), 23 deletions(-)

diffs (91 lines):

diff -r f02da13f721f -r 1510a55ff27e sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Sun May 15 07:01:36 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Sun May 15 07:17:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.91 2016/05/15 07:01:36 maxv Exp $ */
+/*     $NetBSD: locore.S,v 1.92 2016/05/15 07:17:53 maxv Exp $ */
 
 /*
  * Copyright-o-rama!
@@ -654,22 +654,21 @@
        orl     $(PG_V|PG_KW),%eax
        fillkpt_nox
 
-       /*
-        * We actually have to be careful here. The memory layout is as
-        * follows:
-        *    +----------+---------------------+------------------+
-        *    | DATA+BSS < [PRELOADED MODULES] | BOOTSTRAP TABLES >
-        *    +----------+---------------------+------------------+
-        * We just map everything from < to > with RWX rights.
-        */
+       /* Map [SYMS]+[PRELOADED MODULES] RWX. */
        movl    $RELOC(__kernel_end),%eax
        movl    %esi,%ecx               /* start of BOOTSTRAP TABLES */
-       addl    $TABLESIZE,%ecx         /* end of BOOTSTRAP TABLES */
-       subl    %eax,%ecx               /* subtract end of kernel image */
+       subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
        orl     $(PG_V|PG_KW),%eax
        fillkpt
 
+       /* Map the BOOTSTRAP TABLES RW. */
+       movl    %esi,%eax               /* start of BOOTSTRAP TABLES */
+       movl    $TABLESIZE,%ecx         /* length of BOOTSTRAP TABLES */
+       shrl    $PGSHIFT,%ecx
+       orl     $(PG_V|PG_KW),%eax
+       fillkpt_nox
+
        /* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
        movl    $(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax
        movl    $(IOM_SIZE>>PGSHIFT),%ecx
diff -r f02da13f721f -r 1510a55ff27e sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Sun May 15 07:01:36 2016 +0000
+++ b/sys/arch/i386/i386/locore.S       Sun May 15 07:17:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.123 2016/05/15 07:01:36 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.124 2016/05/15 07:17:53 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.123 2016/05/15 07:01:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.124 2016/05/15 07:17:53 maxv Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -718,22 +718,21 @@
        orl     $(PG_V|PG_KW),%eax
        fillkpt_nox
 
-       /*
-        * We actually have to be careful here. The memory layout is as
-        * follows:
-        *    +----------+---------------------+------------------+
-        *    | DATA+BSS < [PRELOADED MODULES] | BOOTSTRAP TABLES >
-        *    +----------+---------------------+------------------+
-        * We just map everything from < to > with RWX rights.
-        */
+       /* Map [SYMS]+[PRELOADED MODULES] RWX. */
        movl    $RELOC(__kernel_end),%eax
        movl    %esi,%ecx               /* start of BOOTSTRAP TABLES */
-       addl    RELOC(tablesize),%ecx   /* end of BOOTSTRAP TABLES */
-       subl    %eax,%ecx               /* subtract end of kernel image */
+       subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
        orl     $(PG_V|PG_KW),%eax
        fillkpt
 
+       /* Map the BOOTSTRAP TABLES RW. */
+       movl    %esi,%eax               /* start of BOOTSTRAP TABLES */
+       movl    RELOC(tablesize),%ecx   /* length of BOOTSTRAP TABLES */
+       shrl    $PGSHIFT,%ecx
+       orl     $(PG_V|PG_KW),%eax
+       fillkpt_nox
+
        /* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
        movl    $(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax
        movl    $(IOM_SIZE>>PGSHIFT),%ecx



Home | Main Index | Thread Index | Old Index