From c0ba567af11a6fdb7686fb43a60b9e0bd6c6a744 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 27 Jul 2023 09:49:15 +0000 Subject: [PATCH] ANDROID: GKI: bring back find_extend_vma() In commit 8d7071af8907 ("mm: always expand the stack with the mmap write lock held"), find_extend_vma() was no longer being used in the tree, so it was removed. Unfortunately some GKI external module is using this, so bring it back to allow things to continue to work. Bug: 161946584 Fixes: 8d7071af8907 ("mm: always expand the stack with the mmap write lock held") Change-Id: I6f1fb1fd8193625fe3dac0bbc5b0aff653b3d879 Cc: Suren Baghdasaryan Signed-off-by: Greg Kroah-Hartman --- include/linux/mm.h | 1 + mm/mmap.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index a9a1b9f9f97c..62ce759bdcff 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3094,6 +3094,7 @@ unsigned long change_prot_numa(struct vm_area_struct *vma, unsigned long start, unsigned long end); #endif +struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); struct vm_area_struct *find_extend_vma_locked(struct mm_struct *, unsigned long addr); int remap_pfn_range(struct vm_area_struct *, unsigned long addr, diff --git a/mm/mmap.c b/mm/mmap.c index 75703bcea8a7..a6857acce59f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2231,6 +2231,20 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon } #endif +/* + * ANDROID: Reintroduce find_extend_vma() as it's still used by some external + * modules. It was removed in commit 8d7071af8907 ("mm: always expand the + * stack with the mmap write lock held") + * In the future, everyone should just move to use the correct function instead + * of this old, legacy one. + */ +struct vm_area_struct *find_extend_vma(struct mm_struct *mm, + unsigned long addr) +{ + return find_extend_vma_locked(mm, addr); +} +EXPORT_SYMBOL_GPL(find_extend_vma); + /* * IA64 has some horrid mapping rules: it can expand both up and down, * but with various special rules.