linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mmap bug with drivers that adjust vm_start
@ 2002-03-26  4:00 Benjamin LaHaise
  2002-03-26  4:00 ` David S. Miller
  2002-03-26 16:42 ` Andrea Arcangeli
  0 siblings, 2 replies; 7+ messages in thread
From: Benjamin LaHaise @ 2002-03-26  4:00 UTC (permalink / raw)
  To: Andrea Arcangeli, Marcelo Tosatti; +Cc: linux-mm, linux-kernel

Hello all,

The patch below fixes a problem whereby a vma which has its vm_start 
address changed by the file's mmap operation can result in the vma 
being inserted into the wrong location within the vma tree.  This 
results in page faults not being handled correctly leading to SEGVs, 
as well as various BUG()s hitting on exit of the mm.  The fix is to 
recalculate the insertion point when we know the address has changed.  
Comments?  Patch is against 2.4.19-pre4.

		-ben
-- 
"A man with a bass just walked in,
 and he's putting it down
 on the floor."

:r ~/patches/v2.4.19-pre4-mmap_fix.diff
--- retest.3/mm/mmap.c.org	Mon Mar 25 19:38:10 2002
+++ retest.3/mm/mmap.c	Mon Mar 25 22:40:40 2002
@@ -548,7 +548,14 @@
 	 * Answer: Yes, several device drivers can do it in their
 	 *         f_op->mmap method. -DaveM
 	 */
-	addr = vma->vm_start;
+	if (addr != vma->vm_start) {
+		/* Since addr changed, we rely on the mmap op to prevent 
+		 * collisions with existing vmas and just use find_vma_prepare 
+		 * to update the tree pointers.
+		 */
+		addr = vma->vm_start;
+		find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
+	}
 
 	vma_link(mm, vma, prev, rb_link, rb_parent);
 	if (correct_wcount)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

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

end of thread, other threads:[~2002-03-26 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-26  4:00 [patch] mmap bug with drivers that adjust vm_start Benjamin LaHaise
2002-03-26  4:00 ` David S. Miller
2002-03-26 16:42 ` Andrea Arcangeli
2002-03-26 18:57   ` Benjamin LaHaise
2002-03-26 19:15     ` Andrea Arcangeli
2002-03-26 20:43       ` Benjamin LaHaise
2002-03-26 21:18         ` Andrea Arcangeli

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