From dada960546530f8f29a38c8bd7bdcd3d5cdd640d Mon Sep 17 00:00:00 2001 From: miod Date: Mon, 9 Jan 2023 06:04:14 +0000 Subject: [PATCH] Handle possible PROT_EXEC fault if PROT_READ fails; needed to cope with kern_exec.c 1.241 --- sys/arch/sh/sh/trap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c index 7284e6a9155..e623d4e62f4 100644 --- a/sys/arch/sh/sh/trap.c +++ b/sys/arch/sh/sh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.51 2022/09/12 19:33:34 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.52 2023/01/09 06:04:14 miod 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 $ */ @@ -416,6 +416,10 @@ tlb_exception(struct proc *p, struct trapframe *tf, uint32_t va) } err = uvm_fault(map, va, 0, access_type); + if (usermode && access_type == PROT_READ && err == EACCES) { + access_type = PROT_EXEC; + err = uvm_fault(map, va, 0, access_type); + } /* User stack extension */ if (err == 0 && map != kernel_map) -- 2.20.1