Source-Changes-HG archive

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

[src/netbsd-6-1]: src/sys/kern Pull up following revision(s) (requested by ma...



details:   https://anonhg.NetBSD.org/src/rev/fa23e72228f2
branches:  netbsd-6-1
changeset: 776232:fa23e72228f2
user:      snj <snj%NetBSD.org@localhost>
date:      Fri Aug 18 14:52:43 2017 +0000

description:
Pull up following revision(s) (requested by martin in ticket #1465):
        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 9a8454c574f6 -r fa23e72228f2 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c    Fri Aug 18 05:37:44 2017 +0000
+++ b/sys/kern/kern_malloc.c    Fri Aug 18 14:52:43 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_malloc.c,v 1.138 2012/02/06 12:13:44 drochner Exp $       */
+/*     $NetBSD: kern_malloc.c,v 1.138.8.1 2017/08/18 14:52:43 snj Exp $        */
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.138 2012/02/06 12:13:44 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.138.8.1 2017/08/18 14:52:43 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -113,7 +113,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