From 8487bfead728e4b8f4a3c4da548f6be46adcf4f6 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 9 Jul 2019 23:48:09 +0000 Subject: I wrote the pc-page-writeable and sp-not-MAP_STACK code to be shared, and then ran into the messaging being poor. Then I fixed the messages. But there are two sub-cases of sp-not-MAP_STACK -- one at syscall time, and another at regular userland trap (on some architectures), and I bungled that messaging. Correct that now, while I look for yet another better way... discovered by millert, who ran an pre-MAP_STACK binary. --- sys/arch/alpha/alpha/trap.c | 5 +++-- sys/arch/amd64/amd64/trap.c | 5 +++-- sys/arch/arm/arm/fault.c | 5 +++-- sys/arch/arm64/arm64/trap.c | 5 +++-- sys/arch/hppa/hppa/trap.c | 5 +++-- sys/arch/i386/i386/trap.c | 5 +++-- sys/arch/m88k/m88k/trap.c | 8 +++++--- sys/arch/mips64/mips64/trap.c | 5 +++-- sys/arch/powerpc/powerpc/trap.c | 5 +++-- sys/arch/sh/sh/trap.c | 5 +++-- sys/arch/sparc64/sparc64/trap.c | 5 +++-- 11 files changed, 35 insertions(+), 23 deletions(-) diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 1a5e43869ac..5f4f5b22f62 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.86 2019/06/01 22:42:20 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.87 2019/07/09 23:48:06 deraadt Exp $ */ /* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */ /*- @@ -244,7 +244,8 @@ trap(a0, a1, a2, entry, framep) if (user) { p->p_md.md_tf = framep; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 8b98461f8c4..31737f6706d 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.75 2019/06/01 22:42:20 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.76 2019/07/09 23:48:07 deraadt Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -328,7 +328,8 @@ usertrap(struct trapframe *frame) p->p_md.md_regs = frame; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; diff --git a/sys/arch/arm/arm/fault.c b/sys/arch/arm/arm/fault.c index 5ca1b76f9c9..a8a9a02d0ba 100644 --- a/sys/arch/arm/arm/fault.c +++ b/sys/arch/arm/arm/fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fault.c,v 1.37 2019/06/01 22:42:20 deraadt Exp $ */ +/* $OpenBSD: fault.c,v 1.38 2019/07/09 23:48:08 deraadt Exp $ */ /* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */ /* @@ -208,7 +208,8 @@ data_abort_handler(trapframe_t *tf) if (user) { pcb->pcb_tf = tf; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/arm64/arm64/trap.c b/sys/arch/arm64/arm64/trap.c index 9677e775692..a92ddd06900 100644 --- a/sys/arch/arm64/arm64/trap.c +++ b/sys/arch/arm64/arm64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.23 2019/06/01 22:42:20 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.24 2019/07/09 23:48:07 deraadt Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * All rights reserved. @@ -242,7 +242,8 @@ do_el0_sync(struct trapframe *frame) p->p_addr->u_pcb.pcb_tf = frame; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index 8f6168c63bb..b8ab29b5eb0 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.144 2019/06/01 22:42:20 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.145 2019/07/09 23:48:07 deraadt Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -215,7 +215,8 @@ trap(int type, struct trapframe *frame) if (type & T_USER) { refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index ce8d129f3c5..44737a3db92 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.139 2019/06/01 22:42:21 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.140 2019/07/09 23:48:07 deraadt Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -157,7 +157,8 @@ trap(struct trapframe *frame) type |= T_USER; p->p_md.md_regs = frame; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index db3575b15fa..4b2d6a8f7e1 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.108 2019/06/17 19:04:40 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.109 2019/07/09 23:48:08 deraadt Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -239,7 +239,8 @@ m88100_trap(u_int type, struct trapframe *frame) type += T_USER; p->p_md.md_tf = frame; /* for ptrace/signals */ refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } @@ -682,7 +683,8 @@ m88110_trap(u_int type, struct trapframe *frame) type += T_USER; p->p_md.md_tf = frame; /* for ptrace/signals */ refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index e38baffb762..781cbe047a7 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.137 2019/06/01 22:42:21 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.138 2019/07/09 23:48:08 deraadt Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -261,7 +261,8 @@ trap(struct trapframe *trapframe) if (type & T_USER) { refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index 81c2c351072..6b308410f7a 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.108 2019/06/01 22:42:21 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.109 2019/07/09 23:48:08 deraadt Exp $ */ /* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */ /* @@ -236,7 +236,8 @@ trap(struct trapframe *frame) if (frame->srr1 & PSL_PR) { type |= EXC_USER; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c index 34c6318d375..8f645e46f05 100644 --- a/sys/arch/sh/sh/trap.c +++ b/sys/arch/sh/sh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.38 2019/06/28 05:51:43 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.39 2019/07/09 23:48:08 deraadt Exp $ */ /* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */ /* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */ @@ -173,7 +173,8 @@ general_exception(struct proc *p, struct trapframe *tf, uint32_t va) KDASSERT(p->p_md.md_regs == tf); /* check exception depth */ expevt |= EXP_USER; refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; } diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index ee87497d3e9..77d4d4089ab 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.100 2019/06/01 22:42:21 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.101 2019/07/09 23:48:08 deraadt Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -426,7 +426,8 @@ trap(struct trapframe64 *tf, unsigned type, vaddr_t pc, long tstate) pcb = &p->p_addr->u_pcb; p->p_md.md_tf = tf; /* for ptrace/signals */ refreshcreds(p); - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), "sp", + if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), + "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) return; -- cgit v1.2.3