[Devel] [PATCH RHEL9 COMMIT] oracle/mm: fail exec if stack expansion will overlap another vma

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 23 23:35:46 MSK 2025


The commit is pushed to "branch-rh9-5.14.0-427.44.1.vz9.80.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.44.1.vz9.80.5
------>
commit 652c3d4968cb88a960e71d346b6fb2dceb450c9c
Author: Anthony Yznaga <anthony.yznaga at oracle.com>
Date:   Tue Dec 1 11:56:10 2020 -0800

    oracle/mm: fail exec if stack expansion will overlap another vma
    
    setup_arg_pages() expands the initial stack of a process by 128k or
    to the stack size limit, whichever is smaller.  expand_stack()
    assumes there is no vma between the vma passed to it and the
    address to expand to, so check before calling it.
    
    Orabug: 32387875
    Signed-off-by: Anthony Yznaga <anthony.yznaga at oracle.com>
    Reviewed-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
    
    https://virtuozzo.atlassian.net/browse/VSTOR-96305
    
    (cherry picked from Oracle commit f352f9e2082e61443e81b406273548118fa4a348)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    Feature: oracle/mm: MADV_DOEXEC madvise() flag
---
 fs/exec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index f109cdc4aa37..ac71b84baf72 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -874,8 +874,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
 		stack_base = vma->vm_start - stack_expand;
 #endif
 	current->mm->start_stack = bprm->p;
-	ret = expand_stack(vma, stack_base);
-	if (ret)
+	if (vma != find_extend_vma(mm, stack_base))
 		ret = -EFAULT;
 
 out_unlock:


More information about the Devel mailing list