linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for v6.3 regression] mm/mremap: fix vm_pgoff in vma_merge() case 3
@ 2023-04-27 14:09 Vlastimil Babka
  2023-04-27 14:15 ` Vlastimil Babka
  2023-04-27 14:27 ` Greg KH
  0 siblings, 2 replies; 9+ messages in thread
From: Vlastimil Babka @ 2023-04-27 14:09 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds
  Cc: Liam R. Howlett, lstoakes, regressions, linux-mm, patches,
	linux-kernel, Vlastimil Babka, Jiri Slaby, Fabian Vogt, stable

After upgrading build guests to v6.3, rpm started segfaulting for
specific packages, which was bisected to commit 0503ea8f5ba7 ("mm/mmap:
remove __vma_adjust()"). rpm is doing many mremap() operations with file
mappings of its db. The problem is that in vma_merge() case 3 (we merge
with the next vma, expanding it downwards) vm_pgoff is not adjusted as
it should when vm_start changes. As a result the rpm process most likely
sees data from the wrong offset of the file. Fix the vm_pgoff
calculation.

For case 8 this is a non-functional change as the resulting vm_pgoff is
the same.

Reported-and-bisected-by: Jiri Slaby <jirislaby@kernel.org>
Reported-and-tested-by: Fabian Vogt <fvogt@suse.com>
Link: https://bugzilla.suse.com/show_bug.cgi?id=1210903
Fixes: 0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
---
Hi, I'm sending this patch on top of v6.3 as I think it should be
applied and backported to 6.3-stable rather sooner than later.
This means there would be a small conflict when merging mm/mm-stable
later. Alternatively it could be added to mm/mm-stable and upcoming 6.4
pull request, but then the stable backport would need adjustment.
It's up to Linus and Andrew.

#regzbot introduced: 0503ea8f5ba7 https://bugzilla.suse.com/show_bug.cgi?id=1210903

 mm/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index d5475fbf5729..eefa6f0cda28 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -978,7 +978,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,
 			vma = next;			/* case 3 */
 			vma_start = addr;
 			vma_end = next->vm_end;
-			vma_pgoff = mid->vm_pgoff;
+			vma_pgoff = next->vm_pgoff - pglen;
 			err = 0;
 			if (mid != next) {		/* case 8 */
 				remove = mid;
-- 
2.40.0



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

end of thread, other threads:[~2023-04-28  7:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 14:09 [PATCH for v6.3 regression] mm/mremap: fix vm_pgoff in vma_merge() case 3 Vlastimil Babka
2023-04-27 14:15 ` Vlastimil Babka
2023-04-27 14:27 ` Greg KH
2023-04-27 14:39   ` Vlastimil Babka
2023-04-27 15:12     ` Linus Torvalds
2023-04-28  2:53       ` Linus Torvalds
2023-04-28  7:13         ` Vlastimil Babka
2023-04-28  7:36       ` Greg KH
2023-04-28  6:15   ` Jiri Slaby

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