diff options
author | 2020-10-19 08:19:46 +0000 | |
---|---|---|
committer | 2020-10-19 08:19:46 +0000 | |
commit | 1df985430144d2794da1efe8f5dd20f8495896d1 (patch) | |
tree | d0430fc72ee9daa1beb6c2038cb6f1e342f08d70 /sys/kern/sys_process.c | |
parent | fix SEGV on fatal() errors spotted by dtucker@ (diff) | |
download | wireguard-openbsd-1df985430144d2794da1efe8f5dd20f8495896d1.tar.xz wireguard-openbsd-1df985430144d2794da1efe8f5dd20f8495896d1.zip |
Serialize accesses to "struct vmspace" and document its refcounting.
The underlying vm_space lock is used as a substitute to the KERNEL_LOCK()
in uvm_grow() to make sure `vm_ssize' is not corrupted.
ok anton@, kettenis@
Diffstat (limited to 'sys/kern/sys_process.c')
-rw-r--r-- | sys/kern/sys_process.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 9481d6a7424..4f6bc30cd76 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.83 2020/03/16 11:58:46 mpi Exp $ */ +/* $OpenBSD: sys_process.c,v 1.84 2020/10/19 08:19:46 mpi Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -850,13 +850,12 @@ process_domem(struct proc *curp, struct process *tr, struct uio *uio, int req) if ((error = process_checkioperm(curp, tr)) != 0) return error; - /* XXXCDC: how should locking work here? */ vm = tr->ps_vmspace; if ((tr->ps_flags & PS_EXITING) || (vm->vm_refcnt < 1)) return EFAULT; addr = uio->uio_offset; - vm->vm_refcnt++; + uvmspace_addref(vm); error = uvm_io(&vm->vm_map, uio, (uio->uio_rw == UIO_WRITE) ? UVM_IO_FIXPROT : 0); @@ -892,7 +891,7 @@ process_auxv_offset(struct proc *curp, struct process *tr, struct uio *uiop) if ((tr->ps_flags & PS_EXITING) || (vm->vm_refcnt < 1)) return EFAULT; - vm->vm_refcnt++; + uvmspace_addref(vm); error = uvm_io(&vm->vm_map, &uio, 0); uvmspace_free(vm); |