do not accidentally pass VM_PROT_WRITE|VM_PROT_READ
authorderaadt <deraadt@openbsd.org>
Tue, 4 Feb 1997 17:23:20 +0000 (17:23 +0000)
committerderaadt <deraadt@openbsd.org>
Tue, 4 Feb 1997 17:23:20 +0000 (17:23 +0000)
sys/arch/mvme68k/mvme68k/trap.c
sys/arch/sparc/sparc/trap.c

index 07ba879..fa1dfbc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: trap.c,v 1.12 1997/02/04 12:29:20 deraadt Exp $ */
+/*     $OpenBSD: trap.c,v 1.13 1997/02/04 17:23:20 deraadt Exp $ */
 
 /*
  * Copyright (c) 1995 Theo de Raadt
@@ -549,7 +549,7 @@ copyfault:
                register struct vmspace *vm = NULL;
                register vm_map_t map;
                int rv;
-               vm_prot_t ftype;
+               vm_prot_t ftype, vftype;
                extern vm_map_t kernel_map;
 
                /* vmspace only significant if T_USER */
@@ -574,9 +574,10 @@ copyfault:
                        map = kernel_map;
                else
                        map = &vm->vm_map;
-               if (WRFAULT(code))
+               if (WRFAULT(code)) {
+                       vftype = VM_PROT_WRITE;
                        ftype = VM_PROT_READ | VM_PROT_WRITE;
-               else
+               else
                        ftype = VM_PROT_READ;
                va = trunc_page((vm_offset_t)v);
 
@@ -640,7 +641,7 @@ copyfault:
                        goto dopanic;
                }
                frame.f_pad = code & 0xffff;
-               ucode = ftype;
+               ucode = vftype;
                typ = SEGV_MAPERR;
                i = SIGSEGV;
                break;
index 6556912..d3ebb6e 100644 (file)
@@ -776,7 +776,7 @@ mem_access_fault4m(type, sfsr, sfva, afsr, afva, tf)
        register struct vmspace *vm;
        register vm_offset_t va;
        register int rv;
-       vm_prot_t ftype;
+       vm_prot_t ftype, vftype;
        int onfault;
        u_quad_t sticks;
 #if DEBUG
@@ -928,6 +928,7 @@ static int lastdouble;
        /* Now munch on protections... */
 
        ftype = sfsr & SFSR_AT_STORE ? VM_PROT_READ|VM_PROT_WRITE:VM_PROT_READ;
+       vftype = sfsr & SFSR_AT_STORE ? VM_PROT_WRITE:VM_PROT_READ;
        if (psr & PSR_PS) {
                extern char Lfsbail[];
                if (sfsr & SFSR_AT_TEXT || type == T_TEXTFAULT) {
@@ -1016,7 +1017,7 @@ kfault:
                        tf->tf_npc = onfault + 4;
                        return;
                }
-               trapsignal(p, SIGSEGV, ftype, SEGV_MAPERR, (caddr_t)sfva);
+               trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, (caddr_t)sfva);
        }
 out:
        if ((psr & PSR_PS) == 0) {