diff mbox series

[RFC,21/47] mm: asi: Add support for locally non-sensitive VM_USERMAP pages

Message ID 20220223052223.1202152-22-junaids@google.com (mailing list archive)
State New, archived
Headers show
Series Address Space Isolation for KVM | expand

Commit Message

Junaid Shahid Feb. 23, 2022, 5:21 a.m. UTC
VM_USERMAP pages can be mapped into userspace, which would overwrite
the asi_mm field, so we restore that field when freeing these pages.

Signed-off-by: Junaid Shahid <junaids@google.com>


---
 mm/vmalloc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ea94d8a1e2e9..a89866a926f6 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2424,6 +2424,14 @@  static void asi_unmap_vm_area(struct vm_struct *area)
 	 */
 	if (area->flags & (VM_GLOBAL_NONSENSITIVE | VM_LOCAL_NONSENSITIVE))
 		asi_unmap(area->asi, area->addr, get_vm_area_size(area), true);
+
+	if (area->flags & VM_USERMAP) {
+		uint i;
+
+		for (i = 0; i < area->nr_pages; i++)
+			if (PageLocalNonSensitive(area->pages[i]))
+				area->pages[i]->asi_mm = area->asi->mm;
+	}
 }
 
 #else