aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2022-07-25 20:53:21 +0000
committerMark Johnston <markj@FreeBSD.org>2022-08-09 19:47:40 +0000
commit3ea8c7ad90f75129c52a2b64213c5578af23dc8d (patch)
treeeff922e0b16db31182d16d09232710ef74ad2a85
parent8a44a2c644fc6d4ec1740fcc0b3ff01eac989ddf (diff)
vm_fault: Shoot down shared mappings in vm_fault_copy_entry()
As in vm_fault_cow(), it's possible, albeit rare, for multiple vm_maps to share a shadow object. When copying a page from a backing object into the shadow, all mappings of the source page must therefore be removed. Otherwise, future operations on the object tree may detect that the source page is fully shadowed and thus can be freed. Approved by: so Security: FreeBSD-SA-22:11.vm Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35635 (cherry picked from commit 5c50e900ad779fccbf0a230bfb6a68a3e93ccf60)
-rw-r--r--sys/vm/vm_fault.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index a6c7a6092f40..32b09fc469d7 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -2094,6 +2094,13 @@ again:
VM_OBJECT_WLOCK(dst_object);
goto again;
}
+
+ /*
+ * See the comment in vm_fault_cow().
+ */
+ if (src_object == dst_object &&
+ (object->flags & OBJ_ONEMAPPING) == 0)
+ pmap_remove_all(src_m);
pmap_copy_page(src_m, dst_m);
/*