In the previous commit, FIXPROT would upgrade a PROT_NONE mapping too far.
authorderaadt <deraadt@openbsd.org>
Wed, 25 Jan 2023 23:42:03 +0000 (23:42 +0000)
committerderaadt <deraadt@openbsd.org>
Wed, 25 Jan 2023 23:42:03 +0000 (23:42 +0000)
Correct the logic, still blocking PROT_EXEC
ok anton kettenis

sys/uvm/uvm_map.c

index f99ac26..f5c23a6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_map.c,v 1.307 2023/01/24 00:16:08 deraadt Exp $   */
+/*     $OpenBSD: uvm_map.c,v 1.308 2023/01/25 23:42:03 deraadt Exp $   */
 /*     $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
 
 /*
@@ -4469,9 +4469,12 @@ uvm_map_extract(struct vm_map *srcmap, vaddr_t start, vsize_t len,
                        goto fail2_unmap;
                }
                kernel_map->size += cp_len;
-               if (flags & UVM_EXTRACT_FIXPROT)
-                       newentry->protection = newentry->max_protection &
-                           ~PROT_EXEC;
+
+               /* Figure out the best protection */ 
+               if ((flags & UVM_EXTRACT_FIXPROT) &&
+                   newentry->protection != PROT_NONE)
+                       newentry->protection = newentry->max_protection;
+               newentry->protection &= ~PROT_EXEC;
 
                /*
                 * Step 2: perform pmap copy.