Module Name:    src
Committed By:   maxv
Date:           Tue Nov 14 10:15:40 UTC 2017

Modified Files:
        src/sys/arch/amd64/conf: Makefile.amd64 kern.ldscript.kaslr

Log Message:
Split each kernel section into sub-blocks of approximately 2MB. The newly
created sections are named .origname.i, for example:

        .text -> { .text .text.0 .text.1 .text.2 .text.3 .text.4 }

Each section is randomized independently by the prekern - and in a random
order obviously. As a result we can get intertwined mappings, of the type:

+-------+-----------+------+---------+-----------+-------+-------+------+-
| text1 | NOTMAPPED | bss0 | rodata1 | NOTMAPPED | data2 | text3 | bss1 |
+-------+-----------+------+---------+-----------+-------+-------+------+-

   ---------+-
    rodata0 | ...
   ---------+-

The CTF section is dropped completely, because (a) when split it becomes
enormous for some reason (that I don't quite understand, verily), and (b)
the kernel expects only one CTF and can't handle several of them.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/conf/kern.ldscript.kaslr

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/conf/Makefile.amd64
diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.62 src/sys/arch/amd64/conf/Makefile.amd64:1.63
--- src/sys/arch/amd64/conf/Makefile.amd64:1.62	Tue Nov 14 09:56:26 2017
+++ src/sys/arch/amd64/conf/Makefile.amd64	Tue Nov 14 10:15:40 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.amd64,v 1.62 2017/11/14 09:56:26 maxv Exp $
+#	$NetBSD: Makefile.amd64,v 1.63 2017/11/14 10:15:40 maxv Exp $
 
 # Makefile for NetBSD
 #
@@ -62,7 +62,7 @@ KERN_AS=	library
 ##
 TEXTADDR?=	0xffffffff80200000
 .if defined(KASLR)
-EXTRA_LINKFLAGS=	-r -d
+EXTRA_LINKFLAGS=	--split-by-file=0x200000 -r -d
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
 .else
 EXTRA_LINKFLAGS=	-z max-page-size=0x200000

Index: src/sys/arch/amd64/conf/kern.ldscript.kaslr
diff -u src/sys/arch/amd64/conf/kern.ldscript.kaslr:1.2 src/sys/arch/amd64/conf/kern.ldscript.kaslr:1.3
--- src/sys/arch/amd64/conf/kern.ldscript.kaslr:1.2	Mon Nov 13 20:01:48 2017
+++ src/sys/arch/amd64/conf/kern.ldscript.kaslr	Tue Nov 14 10:15:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript.kaslr,v 1.2 2017/11/13 20:01:48 maxv Exp $	*/
+/*	$NetBSD: kern.ldscript.kaslr,v 1.3 2017/11/14 10:15:40 maxv Exp $	*/
 
 #include "assym.h"
 
@@ -57,4 +57,10 @@ SECTIONS
 	{
 		KEEP(*(.note.netbsd.ident));
 	}
+
+	/DISCARD/ :
+	{
+		*(.SUNW_ctf)
+		*(.SUNW_ctf.*)
+	}
 }

Reply via email to