Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Add a sanity check to ensure that a region being fr...
details: https://anonhg.NetBSD.org/src/rev/f6b029de0a31
branches: trunk
changeset: 481540:f6b029de0a31
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Feb 01 19:37:58 2000 +0000
description:
Add a sanity check to ensure that a region being free()'d is actually
within the KVA range malloc() would return.
diffstat:
sys/kern/kern_malloc.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diffs (27 lines):
diff -r 05b679377120 -r f6b029de0a31 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c Tue Feb 01 19:29:33 2000 +0000
+++ b/sys/kern/kern_malloc.c Tue Feb 01 19:37:58 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_malloc.c,v 1.47 1999/12/03 21:43:20 ragge Exp $ */
+/* $NetBSD: kern_malloc.c,v 1.48 2000/02/01 19:37:58 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -405,6 +405,17 @@
register struct kmemstats *ksp = &kmemstats[type];
#endif
+#ifdef DIAGNOSTIC
+ /*
+ * Ensure that we're free'ing something that we could
+ * have allocated in the first place. That is, check
+ * to see that the address is within kmem_map.
+ */
+ if ((vaddr_t)addr < kmem_map->header.start ||
+ (vaddr_t)addr >= kmem_map->header.end)
+ panic("free: addr %p not within kmem_map", addr);
+#endif
+
kup = btokup(addr);
size = 1 << kup->ku_indx;
kbp = &bucket[kup->ku_indx];
Home |
Main Index |
Thread Index |
Old Index