linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vm_area_struct slab corruption
@ 2003-03-06 12:29 Hugh Dickins
  2003-03-06 22:52 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Hugh Dickins @ 2003-03-06 12:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Petr Vandrovec, Helge Hafting, linux-kernel

Fix vm_area_struct slab corruption due to mremap's move_vma mistaking
(okay, okay, _my_ mistaking) how do_munmap splits vmas in one case.

This patch fits do_munmap to move_vma's expectation: you may well feel
that's the wrong way round to fix it (and not the way I promised a few
days ago), but at present I'm more comfortable with this simpler fix;
and it does seem preferable for do_munmap to reuse the existing vma.

Hugh

--- 2.5.64/mm/mmap.c	Wed Mar  5 07:26:34 2003
+++ linux/mm/mmap.c	Thu Mar  6 11:47:44 2003
@@ -1258,20 +1258,24 @@
  
 	/*
 	 * If we need to split any vma, do it now to save pain later.
+	 *
+	 * Note: mremap's move_vma VM_ACCOUNT handling assumes a partially
+	 * unmapped vm_area_struct will remain in use: so lower split_vma
+	 * places tmp vma above, and higher split_vma places tmp vma below.
 	 */
 	if (start > mpnt->vm_start) {
 		if (split_vma(mm, mpnt, start, 0))
 			return -ENOMEM;
 		prev = mpnt;
-		mpnt = mpnt->vm_next;
 	}
 
 	/* Does it split the last one? */
 	last = find_vma(mm, end);
 	if (last && end > last->vm_start) {
-		if (split_vma(mm, last, end, 0))
+		if (split_vma(mm, last, end, 1))
 			return -ENOMEM;
 	}
+	mpnt = prev? prev->vm_next: mm->mmap;
 
 	/*
 	 * Remove the vma's, and unmap the actual pages


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

end of thread, other threads:[~2003-03-07 11:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 12:29 [PATCH] vm_area_struct slab corruption Hugh Dickins
2003-03-06 22:52 ` Andrew Morton
2003-03-07  5:27   ` Hugh Dickins
2003-03-07  6:00     ` Andrew Morton
2003-03-07 12:59       ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).