From d4c7b6712f195a8861efb56475b39e7679a6ec60 Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Wed, 8 Oct 2008 08:41:20 +0000 Subject: Don't extend amaps beyond what their supposed maximum. This code path is not taken anymore, but it doesn't hurt to be correct. from NetBSD, through mickey in pr 5812 prodded by otto@ --- sys/uvm/uvm_amap.c | 5 ++++- sys/uvm/uvm_map.c | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'sys/uvm') diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index c939baf29cf..4c79f7ee907 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.42 2008/09/12 08:55:41 otto Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.43 2008/10/08 08:41:18 art Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -361,6 +361,9 @@ amap_extend(struct vm_map_entry *entry, vsize_t addsize) * XXXCDC: could we take advantage of a kernel realloc()? */ + if (slotneed >= UVM_AMAP_LARGE) + return E2BIG; + slotalloc = malloc_roundup(slotneed * MALLOC_SLOT_UNIT) / MALLOC_SLOT_UNIT; #ifdef UVM_AMAP_PPREF diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 14a2b536039..61a69aad4d1 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.104 2008/09/23 13:25:46 art Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.105 2008/10/08 08:41:19 art Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -847,10 +847,8 @@ uvm_map_p(struct vm_map *map, vaddr_t *startp, vsize_t size, if (prev_entry->aref.ar_amap) { error = amap_extend(prev_entry, size); - if (error) { - vm_map_unlock(map); - return (error); - } + if (error) + goto step3; } UVMCNT_INCR(map_backmerge); -- cgit v1.2.3