Module Name: src
Committed By: martin
Date: Tue Jan 21 11:15:52 UTC 2020
Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: fault.c pmap.c
Log Message:
Pull up following revision(s) (requested by ryo in ticket #618):
sys/arch/aarch64/aarch64/fault.c: revision 1.11
sys/arch/aarch64/aarch64/pmap.c: revision 1.61
fix behaviour mmap()/mprotect() when passed only PROT_EXEC.
when mmap()/mprotect() with only PROT_EXEC, syscall will be successful,
but the page actually hadn't been mapped.
it should be mapped with PROT_READ|PROT_EXEC implicitly. (r-x)
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.2.1 src/sys/arch/aarch64/aarch64/fault.c
cvs rdiff -u -r1.41.2.4 -r1.41.2.5 src/sys/arch/aarch64/aarch64/pmap.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/aarch64/aarch64/fault.c
diff -u src/sys/arch/aarch64/aarch64/fault.c:1.10 src/sys/arch/aarch64/aarch64/fault.c:1.10.2.1
--- src/sys/arch/aarch64/aarch64/fault.c:1.10 Mon Jun 10 05:56:15 2019
+++ src/sys/arch/aarch64/aarch64/fault.c Tue Jan 21 11:15:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fault.c,v 1.10 2019/06/10 05:56:15 ryo Exp $ */
+/* $NetBSD: fault.c,v 1.10.2.1 2020/01/21 11:15:52 martin Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.10 2019/06/10 05:56:15 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.10.2.1 2020/01/21 11:15:52 martin Exp $");
#include "opt_compat_netbsd32.h"
#include "opt_ddb.h"
@@ -170,7 +170,7 @@ data_abort_handler(struct trapframe *tf,
}
if ((eclass == ESR_EC_INSN_ABT_EL0) || (eclass == ESR_EC_INSN_ABT_EL1))
- ftype = VM_PROT_READ | VM_PROT_EXECUTE;
+ ftype = VM_PROT_EXECUTE;
else if (__SHIFTOUT(esr, ESR_ISS_DATAABORT_CM))
ftype = VM_PROT_READ;
else
Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.4 src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.5
--- src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.4 Sun Dec 29 09:27:09 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c Tue Jan 21 11:15:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.41.2.4 2019/12/29 09:27:09 martin Exp $ */
+/* $NetBSD: pmap.c,v 1.41.2.5 2020/01/21 11:15:52 martin Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.4 2019/12/29 09:27:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.5 2020/01/21 11:15:52 martin Exp $");
#include "opt_arm_debug.h"
#include "opt_ddb.h"
@@ -1210,6 +1210,10 @@ pmap_protect(struct pmap *pm, vaddr_t sv
KASSERT_PM_ADDR(pm, sva);
KASSERT(!IN_KSEG_ADDR(sva));
+ /* PROT_EXEC requires implicit PROT_READ */
+ if (prot & VM_PROT_EXECUTE)
+ prot |= VM_PROT_READ;
+
if ((prot & VM_PROT_READ) == VM_PROT_NONE) {
PMAP_COUNT(protect_remove_fallback);
pmap_remove(pm, sva, eva);
@@ -2123,6 +2127,10 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
/* ignore except read/write */
accessprot &= (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ /* PROT_EXEC requires implicit PROT_READ */
+ if (accessprot & VM_PROT_EXECUTE)
+ accessprot |= VM_PROT_READ;
+
/* no permission to read/write/execute for this page */
if ((pmap_prot & accessprot) != accessprot) {
UVMHIST_LOG(pmaphist, "no permission to access", 0, 0, 0, 0);