summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-07-14 12:20:32 +0000
committerbluhm <bluhm@openbsd.org>2017-07-14 12:20:32 +0000
commit68ad1399bd1b3b3335fe1973954ac9e9cee6f80c (patch)
tree345636e2450de4223d3ea7d968d35374f7688120
parentAdd some more i2c glue to reduce the diffs to Linux. (diff)
downloadwireguard-openbsd-68ad1399bd1b3b3335fe1973954ac9e9cee6f80c.tar.xz
wireguard-openbsd-68ad1399bd1b3b3335fe1973954ac9e9cee6f80c.zip
The regress test src/regress/sys/kern/siginfo-fault checks whether
the si_code is SEGV_ACCERR after memory access with wrong permissions has triggert a SIGSEGV. Adapt the behavior of i386 and amd64 kernel. Remove the useless code that changed error from EACCES to EFAULT in amd64. Also convert variable name rv to errno in i386 to make it look like amd64. OK kettenis@
-rw-r--r--sys/arch/amd64/amd64/trap.c8
-rw-r--r--sys/arch/i386/i386/trap.c15
2 files changed, 11 insertions, 12 deletions
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index d57493248ab..745dc549961 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.54 2017/04/30 13:04:49 mpi Exp $ */
+/* $OpenBSD: trap.c,v 1.55 2017/07/14 12:20:32 bluhm Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
@@ -362,9 +362,6 @@ faultcommon:
KERNEL_UNLOCK();
goto out;
}
- if (error == EACCES) {
- error = EFAULT;
- }
if (type == T_PAGEFLT) {
if (pcb->pcb_onfault != 0) {
@@ -389,7 +386,8 @@ faultcommon:
frame_dump(frame);
#endif
sv.sival_ptr = (void *)fa;
- trapsignal(p, SIGSEGV, T_PAGEFLT, SEGV_MAPERR, sv);
+ trapsignal(p, SIGSEGV, T_PAGEFLT,
+ error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv);
}
KERNEL_UNLOCK();
break;
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 018c17afd11..a8d770aa20a 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.130 2017/04/30 13:04:49 mpi Exp $ */
+/* $OpenBSD: trap.c,v 1.131 2017/07/14 12:20:32 bluhm Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -373,7 +373,7 @@ trap(struct trapframe *frame)
vaddr_t va, fa;
struct vmspace *vm;
struct vm_map *map;
- int rv;
+ int error;
cr2 = rcr2();
KERNEL_LOCK();
@@ -406,12 +406,12 @@ trap(struct trapframe *frame)
if (curcpu()->ci_inatomic == 0 || map == kernel_map) {
onfault = p->p_addr->u_pcb.pcb_onfault;
p->p_addr->u_pcb.pcb_onfault = NULL;
- rv = uvm_fault(map, va, 0, ftype);
+ error = uvm_fault(map, va, 0, ftype);
p->p_addr->u_pcb.pcb_onfault = onfault;
} else
- rv = EFAULT;
+ error = EFAULT;
- if (rv == 0) {
+ if (error == 0) {
if (map != kernel_map)
uvm_grow(p, va);
if (type == T_PAGEFLT) {
@@ -428,11 +428,12 @@ trap(struct trapframe *frame)
goto copyfault;
}
printf("uvm_fault(%p, 0x%lx, 0, %d) -> %x\n",
- map, va, ftype, rv);
+ map, va, ftype, error);
goto we_re_toast;
}
sv.sival_int = fa;
- trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv);
+ trapsignal(p, SIGSEGV, vftype,
+ error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv);
KERNEL_UNLOCK();
break;
}