• Xiu Jianfeng's avatar
    mm: remove duplicated vma->vm_flags check when expanding stack · 7fa38d0e
    Xiu Jianfeng authored
    expand_upwards() and expand_downwards() will return -EFAULT if VM_GROWSUP
    or VM_GROWSDOWN is not correctly set in vma->vm_flags, however in
    !CONFIG_STACK_GROWSUP case, expand_stack_locked() returns -EINVAL first if
    !(vma->vm_flags & VM_GROWSDOWN) before calling expand_downwards(), to keep
    the consistency with CONFIG_STACK_GROWSUP case, remove this check.
    
    The usages of this function are as below:
    
    A:fs/exec.c
    ret = expand_stack_locked(vma, stack_base);
    if (ret)
    	ret = -EFAULT;
    
    or
    
    B:mm/memory.c mm/mmap.c
    if (expand_stack_locked(vma, addr))
    	return NULL;
    
    which means the return value will not propagate to other places, so I
    believe there is no user-visible effects of this change, and it's
    unnecessary to backport to earlier versions.
    
    Link: https://lkml.kernel.org/r/20230906103312.645712-1-xiujianfeng@huaweicloud.com
    Fixes: f440fa1a ("mm: make find_extend_vma() fail if write lock not held")
    Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
    Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    7fa38d0e
mmap.c 104 KB