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

Junaid Shahid
2022-02-23T05:26:18Z

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 --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
--
2.35.1.473.g83b2b277ed-goog