Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Enable KMEM_REDZONE on DIAGNOSTIC. It will try to c...
details: https://anonhg.NetBSD.org/src/rev/9f5927c7fd03
branches: trunk
changeset: 330799:9f5927c7fd03
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jul 22 07:38:41 2014 +0000
description:
Enable KMEM_REDZONE on DIAGNOSTIC. It will try to catch overflows.
No comment on tech-kern@
diffstat:
sys/kern/subr_kmem.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (58 lines):
diff -r 58f7be00f05b -r 9f5927c7fd03 sys/kern/subr_kmem.c
--- a/sys/kern/subr_kmem.c Tue Jul 22 04:55:51 2014 +0000
+++ b/sys/kern/subr_kmem.c Tue Jul 22 07:38:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kmem.c,v 1.59 2014/07/03 08:43:49 maxv Exp $ */
+/* $NetBSD: subr_kmem.c,v 1.60 2014/07/22 07:38:41 maxv Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -65,13 +65,23 @@
* Prefix each allocations with a fixed-sized, aligned header and record
* the exact user-requested allocation size in it. When freeing, compare
* it with kmem_free's "size" argument.
- */
-
-/*
+ *
* KMEM_REDZONE: detect overrun bugs.
* Add a 2-byte pattern (allocate one more memory chunk if needed) at the
* end of each allocated buffer. Check this pattern on kmem_free.
*
+ * These options are enabled on DIAGNOSTIC.
+ *
+ * |CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+-----+---+-+--+--+
+ * |/////| | | | | | | | | |*|**|UU|
+ * |/HSZ/| | | | | | | | | |*|**|UU|
+ * |/////| | | | | | | | | |*|**|UU|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+-----+---+-+--+--+
+ * |Size | Buffer usable by the caller (requested size) |RedZ|Unused\
+ */
+
+/*
* KMEM_POISON: detect modify-after-free bugs.
* Fill freed (in the sense of kmem_free) memory with a garbage pattern.
* Check the pattern on allocation.
@@ -90,7 +100,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.59 2014/07/03 08:43:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.60 2014/07/22 07:38:41 maxv Exp $");
#include <sys/param.h>
#include <sys/callback.h>
@@ -168,11 +178,11 @@
#if defined(DIAGNOSTIC) && defined(_HARDKERNEL)
#define KMEM_SIZE
+#define KMEM_REDZONE
#endif /* defined(DIAGNOSTIC) */
#if defined(DEBUG) && defined(_HARDKERNEL)
#define KMEM_POISON
-#define KMEM_REDZONE
#define KMEM_GUARD
#endif /* defined(DEBUG) */
Home |
Main Index |
Thread Index |
Old Index