For minherit(MAP_INHERIT_ZERO) upon readonly memory return EPERM.
authorderaadt <deraadt@openbsd.org>
Sun, 21 Jan 2024 16:59:15 +0000 (16:59 +0000)
committerderaadt <deraadt@openbsd.org>
Sun, 21 Jan 2024 16:59:15 +0000 (16:59 +0000)
ok kettenis

sys/uvm/uvm_map.c

index 0cc03de..34c37cc 100644 (file)
@@ -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);
        }