Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Need to keep track of the requested size, when real...
details: https://anonhg.NetBSD.org/src/rev/7b790efe7653
branches: trunk
changeset: 992247:7b790efe7653
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Aug 21 07:56:53 2018 +0000
description:
Need to keep track of the requested size, when realloc is used under kASan.
Maybe we could use mh_rqsz by default.
diffstat:
sys/kern/kern_malloc.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (52 lines):
diff -r f8a96c2b8109 -r 7b790efe7653 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c Tue Aug 21 06:49:21 2018 +0000
+++ b/sys/kern/kern_malloc.c Tue Aug 21 07:56:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_malloc.c,v 1.149 2018/08/21 01:25:57 pgoyette Exp $ */
+/* $NetBSD: kern_malloc.c,v 1.150 2018/08/21 07:56:53 maxv Exp $ */
/*
* Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.149 2018/08/21 01:25:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.150 2018/08/21 07:56:53 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_kasan.h"
@@ -101,7 +101,10 @@
* Header contains total size, including the header itself.
*/
struct malloc_header {
- size_t mh_size;
+ size_t mh_size;
+#ifdef KASAN
+ size_t mh_rqsz;
+#endif
} __aligned(ALIGNBYTES + 1);
void *
@@ -139,6 +142,9 @@
}
mh = (void *)((char *)p + hdroffset);
mh->mh_size = allocsize - hdroffset;
+#ifdef KASAN
+ mh->mh_rqsz = origsize;
+#endif
mh++;
#ifdef KASAN
@@ -195,7 +201,11 @@
mh = curaddr;
mh--;
+#ifdef KASAN
+ cursize = mh->mh_rqsz;
+#else
cursize = mh->mh_size - sizeof(struct malloc_header);
+#endif
/*
* If we already actually have as much as they want, we're done.
Home |
Main Index |
Thread Index |
Old Index