Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/arm32 Handle EINVAL in the fault path and send ...



details:   https://anonhg.NetBSD.org/src/rev/11aed10980d1
branches:  trunk
changeset: 336453:11aed10980d1
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 02 13:36:36 2015 +0000

description:
Handle EINVAL in the fault path and send SIGBUS for mmap acces past EOF.

diffstat:

 sys/arch/arm/arm32/fault.c |  23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diffs (49 lines):

diff -r ebf602362971 -r 11aed10980d1 sys/arch/arm/arm32/fault.c
--- a/sys/arch/arm/arm32/fault.c        Mon Mar 02 12:07:27 2015 +0000
+++ b/sys/arch/arm/arm32/fault.c        Mon Mar 02 13:36:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fault.c,v 1.102 2014/10/25 10:58:12 skrll Exp $        */
+/*     $NetBSD: fault.c,v 1.103 2015/03/02 13:36:36 martin Exp $       */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
 #include "opt_kgdb.h"
 
 #include <sys/types.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.102 2014/10/25 10:58:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.103 2015/03/02 13:36:36 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -507,15 +507,26 @@
 
        KSI_INIT_TRAP(&ksi);
 
-       if (error == ENOMEM) {
+       switch (error) {
+       case ENOMEM:
                printf("UVM: pid %d (%s), uid %d killed: "
                    "out of swap\n", l->l_proc->p_pid, l->l_proc->p_comm,
                    l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1);
                ksi.ksi_signo = SIGKILL;
-       } else
+               break;
+       case EACCES:
                ksi.ksi_signo = SIGSEGV;
-
-       ksi.ksi_code = (error == EACCES) ? SEGV_ACCERR : SEGV_MAPERR;
+               ksi.ksi_code = SEGV_ACCERR;
+               break;
+       case EINVAL:
+               ksi.ksi_signo = SIGBUS;
+               ksi.ksi_code = BUS_ADRERR;
+               break;
+       default:
+               ksi.ksi_signo = SIGSEGV;
+               ksi.ksi_code = SEGV_MAPERR;
+               break;
+       }
        ksi.ksi_addr = (uint32_t *)(intptr_t) far;
        ksi.ksi_trap = fsr;
        UVMHIST_LOG(maphist, " <- error (%d)", error, 0, 0, 0);



Home | Main Index | Thread Index | Old Index