From 6bffaeed6b38758ab18441db1c3bb407d06553de Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 21 Jan 2024 16:59:15 +0000 Subject: [PATCH] For minherit(MAP_INHERIT_ZERO) upon readonly memory return EPERM. ok kettenis --- sys/uvm/uvm_map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 0cc03de7331..34c37cc0d2e 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.324 2024/01/21 16:57:06 deraadt Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.325 2024/01/21 16:59:15 deraadt Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -4199,6 +4199,9 @@ uvm_map_inherit(struct vm_map *map, vaddr_t start, vaddr_t end, while (entry1 != NULL && entry1->start < end) { if (entry1->etype & UVM_ET_IMMUTABLE) goto out; + if (new_inheritance == MAP_INHERIT_ZERO && + (entry1->protection & PROT_WRITE) == 0) + goto out; entry1 = RBT_NEXT(uvm_map_addr, entry1); } -- 2.20.1