mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm: remove duplicated vma->vm_flags check when expanding stack
@ 2023-09-06 10:33 Xiu Jianfeng
  2023-09-10 21:26 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Xiu Jianfeng @ 2023-09-06 10:33 UTC (permalink / raw)
  To: akpm, Liam.Howlett, willy; +Cc: linux-mm, linux-kernel, xiujianfeng

From: Xiu Jianfeng <xiujianfeng@huawei.com>

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.

Fixes: f440fa1ac955 ("mm: make find_extend_vma() fail if write lock not held")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 mm/mmap.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index b56a7f0c9f85..ed4848db7515 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2159,8 +2159,6 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
 #else
 int expand_stack_locked(struct vm_area_struct *vma, unsigned long address)
 {
-	if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
-		return -EINVAL;
 	return expand_downwards(vma, address);
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: remove duplicated vma->vm_flags check when expanding stack
  2023-09-06 10:33 [PATCH] mm: remove duplicated vma->vm_flags check when expanding stack Xiu Jianfeng
@ 2023-09-10 21:26 ` Andrew Morton
  2023-09-11  2:04   ` Xiu Jianfeng
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2023-09-10 21:26 UTC (permalink / raw)
  To: Xiu Jianfeng; +Cc: Liam.Howlett, willy, linux-mm, linux-kernel, xiujianfeng

On Wed,  6 Sep 2023 10:33:12 +0000 Xiu Jianfeng <xiujianfeng@huaweicloud.com> wrote:

> 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.

What are the user-visible effects of this change?

Do you believe this fix should be backported into earlier kernel versions?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: remove duplicated vma->vm_flags check when expanding stack
  2023-09-10 21:26 ` Andrew Morton
@ 2023-09-11  2:04   ` Xiu Jianfeng
  0 siblings, 0 replies; 3+ messages in thread
From: Xiu Jianfeng @ 2023-09-11  2:04 UTC (permalink / raw)
  To: Andrew Morton, Xiu Jianfeng; +Cc: Liam.Howlett, willy, linux-mm, linux-kernel

Hi,

On 2023/9/11 5:26, Andrew Morton wrote:
> On Wed,  6 Sep 2023 10:33:12 +0000 Xiu Jianfeng <xiujianfeng@huaweicloud.com> wrote:
> 
>> 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.
> 
> What are the user-visible effects of this change?
> 
> Do you believe this fix should be backported into earlier kernel versions?

The usages of this function are as bellow:

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-11  2:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06 10:33 [PATCH] mm: remove duplicated vma->vm_flags check when expanding stack Xiu Jianfeng
2023-09-10 21:26 ` Andrew Morton
2023-09-11  2:04   ` Xiu Jianfeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®