diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-07 22:16:36 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-07 22:16:36 +0000 |
commit | 22f48925353e2e2e985a7eefd4a3d59d7dadde16 (patch) | |
tree | 515ec7a80cf8f9ffaeb3cb471b6e1d2d6adff6e9 /sys/kern/kern_sysctl.c | |
parent | c62055b4d0abeee6d1d28d73cc3adfe58e68a0e8 (diff) |
Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 387d39f0184..9ee8ca8ba93 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.41 2001/04/06 23:41:02 art Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.42 2001/05/07 22:16:35 art Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -164,6 +164,7 @@ sys___sysctl(p, v, retval) return (error); if (SCARG(uap, old) != NULL) { #if defined(UVM) + /* XXX - obsolete now that vslock returns an error? */ if (!uvm_useracc(SCARG(uap, old), oldlen, B_WRITE)) #else if (!useracc(SCARG(uap, old), oldlen, B_WRITE)) @@ -173,7 +174,11 @@ sys___sysctl(p, v, retval) return (error); if (dolock) #if defined(UVM) - uvm_vslock(p, SCARG(uap, old), oldlen, VM_PROT_NONE); + if (uvm_vslock(p, SCARG(uap, old), oldlen, + VM_PROT_READ|VM_PROT_WRITE) != KERN_SUCCESS) { + lockmgr(&sysctl_lock, LK_RELEASE, NULL, p); + return EFAULT; + } #else vslock(SCARG(uap, old), oldlen); #endif |