FAILED: patch "[PATCH] mmap: fix vma_iterator in error path of vma_merge()" failed to apply to 6.5-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.5-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.5.y
git checkout FETCH_HEAD
git cherry-pick -x 1419430c8abb5a00590169068590dd54d86590ba
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023102731-olympics-bullpen-6897@gregkh' --subject-prefix 'PATCH 6.5.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 1419430c8abb5a00590169068590dd54d86590ba Mon Sep 17 00:00:00 2001
From: "Liam R. Howlett" <[email protected]>
Date: Fri, 29 Sep 2023 14:30:39 -0400
Subject: [PATCH] mmap: fix vma_iterator in error path of vma_merge()
During the error path, the vma iterator may not be correctly positioned or set to the correct range. Undo the vma_prev() call by resetting to the passed in address. Re-walking to the same range will fix the range to the area previously passed in.
Users would notice increased cycles as vma_merge() would be called an extra time with vma == prev, and thus would fail to merge and return.
mm/mmap.c +8 -2
@@ -975,7 +975,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,/* Error in anon_vma clone. */ if (err) -return NULL ; + goto anon_vma_fail;if (vma_start < vma->vm_start || vma_end > vma->vm_end) vma_expanded = true;
@@ -988,7 +988,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, }if (vma_iter_prealloc (vmi, vma)) -return NULL ; + goto prealloc_fail;init_multi_vma_prep (&vp, vma, adjust, remove, remove2); VM_WARN_ON(vp.anon_vma && adjust && adjust->anon_vma &&
@@ -1016,6 +1016,12 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,vma_complete (&vp, vmi, mm);khugepaged_enter_vma (res, vm_flags);return res; + +prealloc_fail: +anon_vma_fail: +vma_iter_set (vmi, addr); +vma_iter_load (vmi); +return NULL ; }/*
PATCH 1/1 mmap: fix vma_iterator in error path of vma_merge()
commit 1419430c8abb5a00590169068590dd54d86590ba upstream.
During the error path, the vma iterator may not be correctly positioned or set to the correct range. Undo the vma_prev() call by resetting to the passed in address. Re-walking to the same range will fix the range to the area previously passed in.
Users would notice increased cycles as vma_merge() would be called an extra time with vma == prev, and thus would fail to merge and return.
--- mm/mmap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/mmap.c +8 -2
@@ -988,10 +988,10 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,/* Error in anon_vma clone. */ if (err) -return NULL ; + goto anon_vma_fail;if (vma_iter_prealloc (vmi)) -return NULL ; + goto prealloc_fail;init_multi_vma_prep (&vp, vma, adjust, remove, remove2); VM_WARN_ON(vp.anon_vma && adjust && adjust->anon_vma &&
@@ -1024,6 +1024,12 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,khugepaged_enter_vma (res, vm_flags);return res; + +prealloc_fail: +anon_vma_fail: +vma_iter_set (vmi, addr); +vma_iter_load (vmi); +return NULL ; }/*
Signature · 1 line
2.40.1