mm-abstract-get_arg_page-stack-expansion-and-mmap-read-lock.patch removed from -mm tree
The quilt patch titled
Subject: mm: abstract get_arg_page() stack expansion and mmap read lock
has been removed from the -mm tree. Its filename was
mm-abstract-get_arg_page-stack-expansion-and-mmap-read-lock.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Lorenzo Stoakes <[email protected]>
Subject: mm: abstract get_arg_page() stack expansion and mmap read lock
Date: Tue, 3 Dec 2024 18:05:10 +0000
Right now fs/exec.c invokes expand_downwards(), an otherwise internal implementation detail of the VMA logic in order to ensure that an arg page can be obtained by get_user_pages_remote().
In order to be able to move the stack expansion logic into mm/vma.c to make it available to userland testing we need to find an alternative approach here.
We do so by providing the mmap_read_lock_maybe_expand() function which also helpfully documents what get_arg_page() is doing here and adds an additional check against VM_GROWSDOWN to make explicit that the stack expansion logic is only invoked when the VMA is indeed a downward-growing stack.
This allows expand_downwards() to become a static function.
Importantly, the VMA referenced by mmap_read_maybe_expand() must NOT be currently user-visible in any way, that is place within an rmap or VMA tree. It must be a newly allocated VMA.
This is the case when exec invokes this function.
---
fs/exec.c | 14 ++--------- include/linux/mm.h | 5 +-- mm/mmap.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 15 deletions(-)
fs/exec.c renamed from fs/exec.c~mm-abstract-get_arg_page-stack-expansion-and-mmap-read-lock +3 -11
@@ -205,18 +205,10 @@ static struct page *get_arg_page(struct/* * Avoid relying on expanding the stack down in GUP (which * does not work for STACK_GROWSUP anyway), and just do it -* by hand ahead of time. +* ahead of time. */ -if (write && pos < vma->vm_start) { -mmap_write_lock (mm); - ret =expand_downwards (vma, pos); -if (unlikely (ret <0 )) { -mmap_write_unlock (mm); -return NULL ; - } -mmap_write_downgrade (mm); - }else -mmap_read_lock (mm); +if (!mmap_read_lock_maybe_expand (mm, vma, pos, write)) +return NULL ;/* * We are doing an exec(). 'current' is the process
include/linux/mm.h renamed from include/linux/mm.h~mm-abstract-get_arg_page-stack-expansion-and-mmap-read-lock +2 -3
@@ -3324,6 +3324,8 @@ extern int __vm_enough_memory(struct mm_extern int insert_vm_struct (struct mm_struct *,struct vm_area_struct *);extern void exit_mmap (struct mm_struct *);int relocate_vma_down (struct vm_area_struct *vma,unsigned long shift); +bool mmap_read_lock_maybe_expand (struct mm_struct *mm,struct vm_area_struct *vma, +unsigned long addr,bool write); static inline int check_data_rlimit(unsigned long rlim, unsigned long new,
@@ -3437,9 +3439,6 @@ extern unsigned long stack_guard_gap;int expand_stack_locked (struct vm_area_struct *vma,unsigned long address);struct vm_area_struct *expand_stack (struct mm_struct * mm,unsigned long addr); -/* CONFIG_STACK_GROWSUP still needs to grow downwards at some places */ -int expand_downwards (struct vm_area_struct *vma,unsigned long address); -/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct *find_vma (struct mm_struct * mm,unsigned long addr); extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
mm/mmap.c renamed from mm/mmap.c~mm-abstract-get_arg_page-stack-expansion-and-mmap-read-lock +53 -1
63 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mips-vdso-prefer-do_mmap-to-mmap_region.patch
mm-make-mmap_region-internal.patch