Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hppa/hppa Send SIGBUS when accessing mmap() past en...
details: https://anonhg.NetBSD.org/src/rev/861751230f7e
branches: trunk
changeset: 336449:861751230f7e
user: martin <martin%NetBSD.org@localhost>
date: Mon Mar 02 11:05:12 2015 +0000
description:
Send SIGBUS when accessing mmap() past end of file (handle EINVAL in fault
path). While there, handle ENOMEM as well.
diffstat:
sys/arch/hppa/hppa/trap.c | 31 ++++++++++++++++++++++++++-----
1 files changed, 26 insertions(+), 5 deletions(-)
diffs (59 lines):
diff -r 39e9cae1f0e6 -r 861751230f7e sys/arch/hppa/hppa/trap.c
--- a/sys/arch/hppa/hppa/trap.c Mon Mar 02 03:17:24 2015 +0000
+++ b/sys/arch/hppa/hppa/trap.c Mon Mar 02 11:05:12 2015 +0000
@@ -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 @@
#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 @@
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);
Home |
Main Index |
Thread Index |
Old Index