Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/kern Pull up following revision(s) (requested by mart...



details:   https://anonhg.NetBSD.org/src/rev/f36219d2af58
branches:  netbsd-7
changeset: 800280:f36219d2af58
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Aug 09 06:32:49 2017 +0000

description:
Pull up following revision(s) (requested by martin in ticket #1461):
        sys/kern/kern_malloc.c: revision 1.146
Avoid integer overflow in kern_malloc(). Reported by Ilja Van Sprundel.

diffstat:

 sys/kern/kern_malloc.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 6a1730ce3059 -r f36219d2af58 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c    Wed Aug 09 06:22:06 2017 +0000
+++ b/sys/kern/kern_malloc.c    Wed Aug 09 06:32:49 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_malloc.c,v 1.143.2.1 2015/03/25 16:54:37 snj Exp $        */
+/*     $NetBSD: kern_malloc.c,v 1.143.2.2 2017/08/09 06:32:49 snj Exp $        */
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.143.2.1 2015/03/25 16:54:37 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.143.2.2 2017/08/09 06:32:49 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -105,7 +105,10 @@
        void *p;
 
        if (size >= PAGE_SIZE) {
-               allocsize = PAGE_SIZE + size; /* for page alignment */
+               if (size > (ULONG_MAX-PAGE_SIZE))
+                       allocsize = ULONG_MAX;  /* this will fail later */
+               else
+                       allocsize = PAGE_SIZE + size; /* for page alignment */
                hdroffset = PAGE_SIZE - sizeof(struct malloc_header);
        } else {
                allocsize = sizeof(struct malloc_header) + size;



Home | Main Index | Thread Index | Old Index