diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2009-06-01 20:53:31 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2009-06-01 20:53:31 +0000 |
commit | 19268a0235511684a7ee9e71b0c3dd8170ff3762 (patch) | |
tree | 86b771d647b2efe697d8ee230e731df6f91ca006 /sys/uvm | |
parent | 8648b27664592bcafda72648c990f943c0674ee5 (diff) |
Deal with wraparound when checking RLIMIT_DATA.
OK guenther@ otto@
Diffstat (limited to 'sys/uvm')
-rw-r--r-- | sys/uvm/uvm_mmap.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 76d65abd04d..7075e42e515 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.73 2009/06/01 19:54:02 oga Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.74 2009/06/01 20:53:30 millert Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -577,8 +577,9 @@ sys_mmap(struct proc *p, void *v, register_t *retval) if ((flags & MAP_ANON) != 0 || ((flags & MAP_PRIVATE) != 0 && (prot & PROT_WRITE) != 0)) { - if (size > - (p->p_rlimit[RLIMIT_DATA].rlim_cur - ptoa(p->p_vmspace->vm_dused))) { + u_int64_t used = ptoa(p->p_vmspace->vm_dused); + if (p->p_rlimit[RLIMIT_DATA].rlim_cur < used || + size > p->p_rlimit[RLIMIT_DATA].rlim_cur - used) { error = ENOMEM; goto out; } |