diff -urN 2.4.19pre4aa1/mm/mmap.c vma/mm/mmap.c --- 2.4.19pre4aa1/mm/mmap.c Tue Mar 26 20:43:07 2002 +++ vma/mm/mmap.c Tue Mar 26 20:48:24 2002 @@ -554,7 +554,26 @@ * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM */ - addr = vma->vm_start; + if (unlikely(addr != vma->vm_start)) { + /* + * It is a bit too late to pretend changing the virtual + * area of the mapping, we just corrupted userspace + * in the do_munmap, so FIXME (not in 2.4 to avoid breaking + * the driver API). + */ + struct vm_area_struct * stale_vma; + /* 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; + stale_vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent); + /* + * Make sure the lowlevel driver did its job right. + */ + if (unlikely(stale_vma && stale_vma->vm_start < vma->vm_end)) + BUG(); + } vma_link(mm, vma, prev, rb_link, rb_parent); if (correct_wcount)