aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_map.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-11-13 15:14:28 +0000
committerMark Johnston <markj@FreeBSD.org>2026-11-17 16:57:23 +0000
commit025ff8ca639b2b9f3d8dea319d93a7915c122313 (patch)
treeba7dc7f527352d3b1b81733a26d4cdc0bd030e5a /sys/vm/vm_map.c
parent768ca3a3d301ed38c2043cd0a49bfd14f6a3c801 (diff)
vm_map: Fix handling of largepage mappings
vm_map_pmap_enter() is not aware of largepage objects and enters their constituent 4KB pages into the pmap. This permits mapping a constituent page after the corresponding largepage object is freed, which can be abused to escalate privileges. Simply don't pass largepage mappings to it. Modify vm_fault_copy_entry() to handle largepage mappings for the case where mprotect() needs to eagerly upgrade protections on a wired largepage mapping. Approved by: so Security: FreeBSD-SA-26:90.vm Security: CVE-2026-127744 Reviewed by: alc, kib Reported by: OpenAI Security Research Team Reported by: Albert at Vexera AI Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D61363
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r--sys/vm/vm_map.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 94dd7d3a19bc..132f5eac0e23 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -1839,7 +1839,8 @@ vm_map_insert1(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
vm_map_try_merge_entries(map, prev_entry, new_entry);
*res = vm_map_try_merge_entries(map, new_entry, next_entry);
- if ((cow & (MAP_PREFAULT | MAP_PREFAULT_PARTIAL)) != 0) {
+ if ((cow & (MAP_PREFAULT | MAP_PREFAULT_PARTIAL)) != 0 &&
+ (cow & MAP_SPLIT_BOUNDARY_MASK) == 0) {
vm_map_pmap_enter(map, start, prot, object, OFF_TO_IDX(offset),
end - start, cow & MAP_PREFAULT_PARTIAL);
}
@@ -3160,7 +3161,8 @@ vm_map_madvise(
vm_offset_t useEnd, useStart;
if ((entry->eflags & (MAP_ENTRY_IS_SUB_MAP |
- MAP_ENTRY_GUARD)) != 0)
+ MAP_ENTRY_GUARD | MAP_ENTRY_SPLIT_BOUNDARY_MASK)) !=
+ 0)
continue;
/*