Deleted Added
full compact
kern_malloc.c (1817) kern_malloc.c (3308)
1/*
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
34 * $Id$
34 * $Id: kern_malloc.c,v 1.3 1994/08/02 07:42:04 davidg Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/proc.h>
40#include <sys/map.h>
41#include <sys/kernel.h>
42#include <sys/malloc.h>

--- 148 unchanged lines hidden (view full) ---

191 va = kbp->kb_next;
192 kbp->kb_next = ((struct freelist *)va)->next;
193#ifdef DIAGNOSTIC
194 freep = (struct freelist *)va;
195 savedtype = (unsigned)freep->type < M_LAST ?
196 memname[freep->type] : "???";
197 if (kbp->kb_next &&
198 !kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/proc.h>
40#include <sys/map.h>
41#include <sys/kernel.h>
42#include <sys/malloc.h>

--- 148 unchanged lines hidden (view full) ---

191 va = kbp->kb_next;
192 kbp->kb_next = ((struct freelist *)va)->next;
193#ifdef DIAGNOSTIC
194 freep = (struct freelist *)va;
195 savedtype = (unsigned)freep->type < M_LAST ?
196 memname[freep->type] : "???";
197 if (kbp->kb_next &&
198 !kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
199 printf("%s of object 0x%x size %d %s %s (invalid addr 0x%x)\n",
199 printf("%s of object %p size %ld %s %s (invalid addr %p)\n",
200 "Data modified on freelist: word 2.5", va, size,
201 "previous type", savedtype, kbp->kb_next);
202 kbp->kb_next = NULL;
203 }
204#if BYTE_ORDER == BIG_ENDIAN
205 freep->type = WEIRD_ADDR >> 16;
206#endif
207#if BYTE_ORDER == LITTLE_ENDIAN
208 freep->type = (short)WEIRD_ADDR;
209#endif
210 if (((long)(&freep->next)) & 0x2)
211 freep->next = (caddr_t)((WEIRD_ADDR >> 16)|(WEIRD_ADDR << 16));
212 else
213 freep->next = (caddr_t)WEIRD_ADDR;
214 end = (long *)&va[copysize];
215 for (lp = (long *)va; lp < end; lp++) {
216 if (*lp == WEIRD_ADDR)
217 continue;
200 "Data modified on freelist: word 2.5", va, size,
201 "previous type", savedtype, kbp->kb_next);
202 kbp->kb_next = NULL;
203 }
204#if BYTE_ORDER == BIG_ENDIAN
205 freep->type = WEIRD_ADDR >> 16;
206#endif
207#if BYTE_ORDER == LITTLE_ENDIAN
208 freep->type = (short)WEIRD_ADDR;
209#endif
210 if (((long)(&freep->next)) & 0x2)
211 freep->next = (caddr_t)((WEIRD_ADDR >> 16)|(WEIRD_ADDR << 16));
212 else
213 freep->next = (caddr_t)WEIRD_ADDR;
214 end = (long *)&va[copysize];
215 for (lp = (long *)va; lp < end; lp++) {
216 if (*lp == WEIRD_ADDR)
217 continue;
218 printf("%s %d of object 0x%x size %d %s %s (0x%x != 0x%x)\n",
218 printf("%s %d of object %p size %ld %s %s (0x%lx != 0x%x)\n",
219 "Data modified on freelist: word", lp - (long *)va,
220 va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
221 break;
222 }
223 freep->spare0 = 0;
224#endif /* DIAGNOSTIC */
225#ifdef KMEMSTATS
226 kup = btokup(va);

--- 76 unchanged lines hidden (view full) ---

303 /*
304 * Check for multiple frees. Use a quick check to see if
305 * it looks free before laboriously searching the freelist.
306 */
307 if (freep->spare0 == WEIRD_ADDR) {
308 for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
309 if (addr != cp)
310 continue;
219 "Data modified on freelist: word", lp - (long *)va,
220 va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
221 break;
222 }
223 freep->spare0 = 0;
224#endif /* DIAGNOSTIC */
225#ifdef KMEMSTATS
226 kup = btokup(va);

--- 76 unchanged lines hidden (view full) ---

303 /*
304 * Check for multiple frees. Use a quick check to see if
305 * it looks free before laboriously searching the freelist.
306 */
307 if (freep->spare0 == WEIRD_ADDR) {
308 for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
309 if (addr != cp)
310 continue;
311 printf("multiply freed item 0x%x\n", addr);
311 printf("multiply freed item %p\n", addr);
312 panic("free: duplicated free");
313 }
314 }
315 /*
316 * Copy in known text to detect modification after freeing
317 * and to make it look free. Also, save the type being freed
318 * so we can list likely culprit if modification is detected
319 * when the object is reallocated.

--- 65 unchanged lines hidden ---
312 panic("free: duplicated free");
313 }
314 }
315 /*
316 * Copy in known text to detect modification after freeing
317 * and to make it look free. Also, save the type being freed
318 * so we can list likely culprit if modification is detected
319 * when the object is reallocated.

--- 65 unchanged lines hidden ---