Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mac68k/mac68k Handle EINVAL in the fault path and s...



details:   https://anonhg.NetBSD.org/src/rev/a63ef926029f
branches:  trunk
changeset: 806639:a63ef926029f
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Mar 03 20:36:31 2015 +0000

description:
Handle EINVAL in the fault path and send SIGBUS on mmap'd access past EOF.

diffstat:

 sys/arch/mac68k/mac68k/trap.c |  25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diffs (59 lines):

diff -r 25f7f634c086 -r a63ef926029f sys/arch/mac68k/mac68k/trap.c
--- a/sys/arch/mac68k/mac68k/trap.c     Tue Mar 03 19:59:48 2015 +0000
+++ b/sys/arch/mac68k/mac68k/trap.c     Tue Mar 03 20:36:31 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $ */
+/*     $NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $        */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -585,11 +585,6 @@
                        }
                        goto out;
                }
-               if (rv == EACCES) {
-                       ksi.ksi_code = SEGV_ACCERR;
-                       rv = EFAULT;
-               } else
-                       ksi.ksi_code = SEGV_MAPERR;
                if (type == T_MMUFLT) {
                        if (onfault)
                                goto copyfault;
@@ -600,14 +595,26 @@
                        goto dopanic;
                }
                ksi.ksi_addr = (void *)v;
-               if (rv == ENOMEM) {
+               switch (rv) {
+               case ENOMEM:
                        printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
                               p->p_pid, p->p_comm,
                               l->l_cred ?
                               kauth_cred_geteuid(l->l_cred) : -1);
                        ksi.ksi_signo = SIGKILL;
-               } else {
+                       break;
+               case EINVAL:
+                       ksi.ksi_signo = SIGBUS;
+                       ksi.ksi_code = BUS_ADRERR;
+                       break;
+               case EACCES:
                        ksi.ksi_signo = SIGSEGV;
+                       ksi.ksi_code = SEGV_ACCERR;
+                       break;
+               default:
+                       ksi.ksi_signo = SIGSEGV;
+                       ksi.ksi_code = SEGV_MAPERR;
+                       break;
                }
                break;
            }



Home | Main Index | Thread Index | Old Index