Module Name: src Committed By: martin Date: Mon Mar 2 11:05:12 UTC 2015
Modified Files: src/sys/arch/hppa/hppa: trap.c Log Message: Send SIGBUS when accessing mmap() past end of file (handle EINVAL in fault path). While there, handle ENOMEM as well. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/arch/hppa/hppa/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/hppa/hppa/trap.c diff -u src/sys/arch/hppa/hppa/trap.c:1.106 src/sys/arch/hppa/hppa/trap.c:1.107 --- src/sys/arch/hppa/hppa/trap.c:1.106 Thu Mar 6 19:02:58 2014 +++ src/sys/arch/hppa/hppa/trap.c Mon Mar 2 11:05:12 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.106 2014/03/06 19:02:58 skrll Exp $ */ +/* $NetBSD: trap.c,v 1.107 2015/03/02 11:05:12 martin Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.106 2014/03/06 19:02:58 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.107 2015/03/02 11:05:12 martin Exp $"); /* #define INTRDEBUG */ /* #define TRAPDEBUG */ @@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.1 #include <sys/acct.h> #include <sys/signal.h> #include <sys/device.h> +#include <sys/kauth.h> #include <sys/kmem.h> #include <sys/userret.h> @@ -881,9 +882,29 @@ do_onfault: user_backtrace(frame, l, type); #endif KSI_INIT_TRAP(&ksi); - ksi.ksi_signo = SIGSEGV; - ksi.ksi_code = (ret == EACCES ? - SEGV_ACCERR : SEGV_MAPERR); + switch (ret) { + case EACCES: + ksi.ksi_signo = SIGSEGV; + ksi.ksi_code = SEGV_ACCERR; + break; + case ENOMEM: + ksi.ksi_signo = SIGKILL; + 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); + 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_trap = type; ksi.ksi_addr = (void *)va; trapsignal(l, &ksi);