Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Unlink KMEM_GUARD leftovers.



details:   https://anonhg.NetBSD.org/src/rev/5d4329260a23
branches:  trunk
changeset: 964762:5d4329260a23
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Aug 15 12:24:08 2019 +0000

description:
Unlink KMEM_GUARD leftovers.

diffstat:

 share/man/man9/kmem.9             |  88 +--------------------------------------
 sys/arch/mips/mips/pmap_machdep.c |  10 +---
 sys/kern/files.kern               |   6 +-
 3 files changed, 6 insertions(+), 98 deletions(-)

diffs (168 lines):

diff -r 069002d9213c -r 5d4329260a23 share/man/man9/kmem.9
--- a/share/man/man9/kmem.9     Thu Aug 15 12:06:42 2019 +0000
+++ b/share/man/man9/kmem.9     Thu Aug 15 12:24:08 2019 +0000
@@ -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 @@
 .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 ,
diff -r 069002d9213c -r 5d4329260a23 sys/arch/mips/mips/pmap_machdep.c
--- a/sys/arch/mips/mips/pmap_machdep.c Thu Aug 15 12:06:42 2019 +0000
+++ b/sys/arch/mips/mips/pmap_machdep.c Thu Aug 15 12:24:08 2019 +0000
@@ -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 @@
        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;
diff -r 069002d9213c -r 5d4329260a23 sys/kern/files.kern
--- a/sys/kern/files.kern       Thu Aug 15 12:06:42 2019 +0000
+++ b/sys/kern/files.kern       Thu Aug 15 12:24:08 2019 +0000
@@ -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_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



Home | Main Index | Thread Index | Old Index