Module Name:    src
Committed By:   maxv
Date:           Thu Aug 15 12:24:09 UTC 2019

Modified Files:
        src/share/man/man9: kmem.9
        src/sys/arch/mips/mips: pmap_machdep.c
        src/sys/kern: files.kern

Log Message:
Unlink KMEM_GUARD leftovers.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/share/man/man9/kmem.9
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/mips/mips/pmap_machdep.c
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/files.kern

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/kmem.9
diff -u src/share/man/man9/kmem.9:1.23 src/share/man/man9/kmem.9:1.24
--- src/share/man/man9/kmem.9:1.23	Tue Nov  7 18:36:27 2017
+++ src/share/man/man9/kmem.9	Thu Aug 15 12:24:08 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kmem.9,v 1.23 2017/11/07 18:36:27 christos Exp $
+.\"	$NetBSD: kmem.9,v 1.24 2019/08/15 12:24:08 maxv Exp $
 .\"
 .\" Copyright (c)2006 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" ------------------------------------------------------------
-.Dd November 7, 2017
+.Dd August 15, 2019
 .Dt KMEM 9
 .Os
 .\" ------------------------------------------------------------
@@ -69,8 +69,6 @@
 .\" ------------------------------------------------------------
 .Pp
 .Cd "options KMEM_SIZE"
-.Cd "options KMEM_REDZONE"
-.Cd "options KMEM_GUARD"
 .Sh DESCRIPTION
 .Fn kmem_alloc
 allocates kernel wired memory.
@@ -260,89 +258,7 @@ Any mismatch triggers a panic.
 .Pp
 .Dv KMEM_SIZE
 is enabled by default on
-.Dv DIAGNOSTIC
-and
-.Dv DEBUG .
-.Ss KMEM_REDZONE
-Kernels compiled with the
-.Dv KMEM_REDZONE
-option add a dynamic pattern of two bytes at the end of each allocated
-buffer, and check this pattern when freeing to ensure the caller hasn't
-written outside the requested area.
-This option does not introduce a significant performance impact,
-but has two drawbacks: it only catches write overflows, and catches
-them only on
-.Fn kmem_free .
-.Pp
-.Dv KMEM_REDZONE
-is enabled by default on
 .Dv DIAGNOSTIC .
-.Ss KMEM_GUARD
-Kernels compiled with the
-.Dv KMEM_GUARD
-option perform CPU intensive sanity checks on kmem operations.
-It adds additional, very high overhead runtime verification to kmem
-operations.
-It must be enabled with
-.Dv KMEM_SIZE .
-.Pp
-.Dv KMEM_GUARD
-tries to catch the following types of bugs:
-.Bl -bullet
-.It
-Overflow at time of occurrence, by means of a guard page.
-An unmapped guard page sits immediately after the requested area;
-a read/write overflow therefore triggers a page fault.
-.It
-Underflow at
-.Fn kmem_free ,
-by using
-.Dv KMEM_SIZE Ap s
-registered size.
-If an underflow occurs, the size stored by
-.Dv KMEM_SIZE
-will be overwritten, which means that when freeing, the kernel will
-spot the mismatch.
-.It
-Use-after-free at time of occurrence.
-When freeing, the memory is unmapped, and depending on the value
-of kmem_guard_depth, the kernel will more or less delay the recycling
-of that memory.
-Which means that any ulterior read/write access to the memory will
-trigger a page fault, given it hasn't been recycled yet.
-.El
-.Pp
-To enable it, boot the system with the
-.Fl d
-option, which causes the debugger to be entered early during the kernel
-boot process.
-Issue commands such as the following:
-.Bd -literal
-db> w kmem_guard_depth 0t30000
-db> c
-.Ed
-.Pp
-This instructs
-.Dv kmem_guard
-to queue up to 60000 (30000*2) pages of unmapped KVA to catch
-use-after-free type errors.
-When
-.Fn kmem_free
-is called, memory backing a freed item is unmapped and the kernel VA
-space pushed onto a FIFO.
-The VA space will not be reused until another 30k items have been freed.
-Until reused the kernel will catch invalid accesses and panic with a page fault.
-Limitations:
-.Bl -bullet
-.It
-It has a severe impact on performance.
-.It
-It is best used on a 64-bit machine with lots of RAM.
-.El
-.Pp
-.Dv KMEM_GUARD
-is enabled by default on
-.Dv DEBUG .
 .Sh RETURN VALUES
 On success,
 .Fn kmem_alloc ,

Index: src/sys/arch/mips/mips/pmap_machdep.c
diff -u src/sys/arch/mips/mips/pmap_machdep.c:1.24 src/sys/arch/mips/mips/pmap_machdep.c:1.25
--- src/sys/arch/mips/mips/pmap_machdep.c:1.24	Sun Jul 14 09:31:33 2019
+++ src/sys/arch/mips/mips/pmap_machdep.c	Thu Aug 15 12:24:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_machdep.c,v 1.24 2019/07/14 09:31:33 skrll Exp $	*/
+/*	$NetBSD: pmap_machdep.c,v 1.25 2019/08/15 12:24:08 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.24 2019/07/14 09:31:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.25 2019/08/15 12:24:08 maxv Exp $");
 
 /*
  *	Manages physical address maps.
@@ -378,12 +378,6 @@ pmap_bootstrap(void)
 	sysmap_size = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
 	    bufsz + 16 * NCARGS + pager_map_size) / NBPG +
 	    (maxproc * UPAGES) + nkmempages;
-#ifdef DEBUG
-	{
-		extern int kmem_guard_depth;
-		sysmap_size += kmem_guard_depth;
-	}
-#endif
 
 #ifdef SYSVSHM
 	sysmap_size += shminfo.shmall;

Index: src/sys/kern/files.kern
diff -u src/sys/kern/files.kern:1.34 src/sys/kern/files.kern:1.35
--- src/sys/kern/files.kern:1.34	Thu Apr  4 20:19:07 2019
+++ src/sys/kern/files.kern	Thu Aug 15 12:24:08 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.kern,v 1.34 2019/04/04 20:19:07 christos Exp $
+#	$NetBSD: files.kern,v 1.35 2019/08/15 12:24:08 maxv Exp $
 
 #
 # kernel sources
@@ -123,9 +123,7 @@ file	kern/subr_ipi.c			kern
 file	kern/subr_kcpuset.c		kern
 file	kern/subr_kleak.c		kleak
 file	kern/subr_kcov.c		kcov
-defflag	opt_kmem.h			KMEM_GUARD
-					KMEM_SIZE
-defparam opt_kmem.h			KMEM_GUARD_DEPTH
+defflag	opt_kmem.h			KMEM_SIZE
 file	kern/subr_kmem.c		kern
 file	kern/subr_kobj.c		kern
 file	kern/subr_kobj_vfs.c		kern

Reply via email to