From f05728038a59f7df31f64c0dcde6890e8e2b970d Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 12 Sep 2018 11:58:28 +0000 Subject: [PATCH] Make pmap_protect(9) actually remove exec permission if the new permissions include PROT_READ but not PROT_EXEC. ok patrick@ --- sys/arch/arm64/arm64/pmap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/arm64/pmap.c b/sys/arch/arm64/arm64/pmap.c index 9beb6047c0d..4cd23d17b71 100644 --- a/sys/arch/arm64/arm64/pmap.c +++ b/sys/arch/arm64/arm64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.57 2018/08/18 15:42:19 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.58 2018/09/12 11:58:28 kettenis Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * @@ -1424,6 +1424,10 @@ pmap_page_ro(pmap_t pm, vaddr_t va, vm_prot_t prot) pted->pted_va &= ~PROT_WRITE; pted->pted_pte &= ~PROT_WRITE; + if ((prot & PROT_EXEC) == 0) { + pted->pted_va &= ~PROT_EXEC; + pted->pted_pte &= ~PROT_EXEC; + } pmap_pte_update(pted, pl3); ttlb_flush(pm, pted->pted_va & ~PAGE_MASK); @@ -1496,7 +1500,7 @@ pmap_protect(pmap_t pm, vaddr_t sva, vaddr_t eva, vm_prot_t prot) if (prot & (PROT_READ | PROT_EXEC)) { pmap_lock(pm); while (sva < eva) { - pmap_page_ro(pm, sva, 0); + pmap_page_ro(pm, sva, prot); sva += PAGE_SIZE; } pmap_unlock(pm); -- 2.20.1