add a check that the arguments to isavail don't overflow.
authortedu <tedu@openbsd.org>
Fri, 29 Jul 2016 20:44:40 +0000 (20:44 +0000)
committertedu <tedu@openbsd.org>
Fri, 29 Jul 2016 20:44:40 +0000 (20:44 +0000)
callers should probably check too, but checking here won't hurt.
possible panic reported by tim newsham.
ok kettenis

sys/uvm/uvm_map.c

index 5050464..254dd4d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_map.c,v 1.217 2016/06/17 10:48:25 dlg Exp $       */
+/*     $OpenBSD: uvm_map.c,v 1.218 2016/07/29 20:44:40 tedu Exp $      */
 /*     $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
 
 /*
@@ -771,6 +771,9 @@ uvm_map_isavail(struct vm_map *map, struct uvm_addr_state *uaddr,
        struct uvm_map_addr *atree;
        struct vm_map_entry *i, *i_end;
 
+       if (addr + sz < addr)
+               return 0;
+
        /*
         * Kernel memory above uvm_maxkaddr is considered unavailable.
         */