Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/uvm Pull up following revision(s) (requested by riast...



details:   https://anonhg.NetBSD.org/src/rev/15822f53ff02
branches:  netbsd-9
changeset: 374114:15822f53ff02
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Apr 01 16:22:14 2023 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1625):

        sys/uvm/uvm_map.c: revision 1.403

mmap(2): Avoid arithmetic overflow in search for free space.

PR kern/56900

diffstat:

 sys/uvm/uvm_map.c |  20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 6338fd728f7e -r 15822f53ff02 sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Apr 01 16:08:05 2023 +0000
+++ b/sys/uvm/uvm_map.c Sat Apr 01 16:22:14 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.362.2.4 2023/04/01 16:03:48 martin Exp $ */
+/*     $NetBSD: uvm_map.c,v 1.362.2.5 2023/04/01 16:22:14 martin Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.362.2.4 2023/04/01 16:03:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.362.2.5 2023/04/01 16:22:14 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -2026,7 +2026,21 @@ uvm_map_findspace(struct vm_map *map, va
        /* Try to find the space in the red-black tree */
 
        /* Check slot before any entry */
-       hint = topdown ? entry->next->start - length : entry->end;
+       if (topdown) {
+               KASSERTMSG(entry->next->start >= vm_map_min(map),
+                   "map=%p entry=%p entry->next=%p"
+                   " entry->next->start=0x%"PRIxVADDR" min=0x%"PRIxVADDR,
+                   map, entry, entry->next,
+                   entry->next->start, vm_map_min(map));
+               if (length > entry->next->start - vm_map_min(map))
+                       hint = vm_map_min(map); /* XXX goto wraparound? */
+               else
+                       hint = entry->next->start - length;
+               KASSERT(hint >= vm_map_min(map));
+       } else {
+               hint = entry->end;
+       }
+
        switch (uvm_map_space_avail(&hint, length, uoffset, align, flags,
            topdown, entry)) {
        case 1:



Home | Main Index | Thread Index | Old Index