mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
UPSTREAM: mm/mmap: Fix extra maple tree write
based on commit0503ea8f5bupstream. This was inadvertently fixed during the removal of __vma_adjust(). When __vma_adjust() is adjusting next with a negative value (pushing vma->vm_end lower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA. Reported-by: John Hsu <John.Hsu@mediatek.com> Link: https://lore.kernel.org/lkml/9cb8c599b1d7f9c1c300d1a334d5eb70ec4d7357.camel@mediatek.com/ Cc: stable@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commita02c6dc0efhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git linux-6.1.y) Bug: 295269894 Change-Id: I1a4bdc080d4ee92dbe06dc788961532d0c85fd7c Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
committed by
Suren Baghdasaryan
parent
f86c79eb86
commit
683966ac69
@@ -801,7 +801,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
|
||||
}
|
||||
if (end != vma->vm_end) {
|
||||
if (vma->vm_end > end) {
|
||||
if (adjust_next >= 0 && !insert) {
|
||||
if ((vma->vm_end + adjust_next != end) &&
|
||||
(!insert || (insert->vm_start != end))) {
|
||||
vma_mas_szero(&mas, end, vma->vm_end);
|
||||
mas_reset(&mas);
|
||||
VM_WARN_ON(insert &&
|
||||
|
||||
Reference in New Issue
Block a user