Swap kernel/curproc tests in copy*_vmspace so rump can catch EFAULT.

This commit is contained in:
riastradh 2015-03-28 16:13:38 +00:00
parent e7f784aa67
commit c287e76ea3
1 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_copy.c,v 1.1 2009/11/04 16:54:00 pooka Exp $ */
/* $NetBSD: subr_copy.c,v 1.2 2015/03/28 16:13:38 riastradh Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.1 2009/11/04 16:54:00 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.2 2015/03/28 16:13:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/fcntl.h>
@ -211,12 +211,12 @@ copyin_vmspace(struct vmspace *vm, const void *uaddr, void *kaddr, size_t len)
if (len == 0)
return (0);
if (VMSPACE_IS_KERNEL_P(vm)) {
return kcopy(uaddr, kaddr, len);
}
if (__predict_true(vm == curproc->p_vmspace)) {
return copyin(uaddr, kaddr, len);
}
if (VMSPACE_IS_KERNEL_P(vm)) {
return kcopy(uaddr, kaddr, len);
}
iov.iov_base = kaddr;
iov.iov_len = len;
@ -244,12 +244,12 @@ copyout_vmspace(struct vmspace *vm, const void *kaddr, void *uaddr, size_t len)
if (len == 0)
return (0);
if (VMSPACE_IS_KERNEL_P(vm)) {
return kcopy(kaddr, uaddr, len);
}
if (__predict_true(vm == curproc->p_vmspace)) {
return copyout(kaddr, uaddr, len);
}
if (VMSPACE_IS_KERNEL_P(vm)) {
return kcopy(kaddr, uaddr, len);
}
iov.iov_base = __UNCONST(kaddr); /* XXXUNCONST cast away const */
iov.iov_len = len;