diff -r -c3 linux-1.1.48/mm/mmap.c linux/mm/mmap.c
*** linux-1.1.48/mm/mmap.c	Sun Aug 14 15:40:56 1994
--- linux/mm/mmap.c	Tue Aug 23 11:11:52 1994
***************
*** 424,429 ****
--- 432,444 ----
  		 */
  		prev->vm_end = mpnt->vm_end;
  		prev->vm_next = mpnt->vm_next;
+ 		if (mpnt->vm_ops && mpnt->vm_ops->close) {
+ 			mpnt->vm_offset += mpnt->vm_end - mpnt->vm_start;
+ 			mpnt->vm_start = mpnt->vm_end;
+ 			mpnt->vm_ops->close(mpnt);
+ 		}
+ 		if (mpnt->vm_inode)
+ 			mpnt->vm_inode->i_count--;
  		kfree_s(mpnt, sizeof(*mpnt));
  		mpnt = prev;
  	}
diff -r -c3 linux-1.1.48/mm/mprotect.c linux/mm/mprotect.c
*** linux-1.1.48/mm/mprotect.c	Sun Aug 14 15:40:56 1994
--- linux/mm/mprotect.c	Sun Aug 14 02:24:34 1994
***************
*** 107,123 ****
  	unsigned long start, unsigned long end,
  	int newflags, int prot)
  {
! 	int error;
! 	unsigned long tmpflags, tmpprot;
  
! 	tmpflags = vma->vm_flags;
! 	tmpprot = vma->vm_page_prot;
  	vma->vm_flags = newflags;
  	vma->vm_page_prot = prot;
! 	error = mprotect_fixup_end(vma, end, tmpflags, tmpprot);
! 	if (!error)
! 		error = mprotect_fixup_start(vma, start, tmpflags, tmpprot);
! 	return error;
  }
  
  static int mprotect_fixup(struct vm_area_struct * vma, 
--- 111,146 ----
  	unsigned long start, unsigned long end,
  	int newflags, int prot)
  {
! 	struct vm_area_struct * left, * right;
  
! 	left = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
! 	if (!left)
! 		return -ENOMEM;
! 	right = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
! 	if (!right) {
! 		kfree(left);
! 		return -ENOMEM;
! 	}
! 	*left = *vma;
! 	*right = *vma;
! 	left->vm_end = start;
! 	vma->vm_start = start;
! 	vma->vm_end = end;
! 	right->vm_start = end;
! 	vma->vm_offset += vma->vm_start - left->vm_start;
! 	right->vm_offset += right->vm_start - left->vm_start;
  	vma->vm_flags = newflags;
  	vma->vm_page_prot = prot;
! 	if (vma->vm_inode)
! 		vma->vm_inode->i_count += 2;
! 	if (vma->vm_ops && vma->vm_ops->dup) {
! 		vma->vm_ops->dup(left);
! 		vma->vm_ops->dup(right);
! 	}
! 	insert_vm_struct(current, left);
! 	insert_vm_struct(current, right);
! 	merge_segments(current->mm->mmap);
! 	return 0;
  }
  
  static int mprotect_fixup(struct vm_area_struct * vma, 
***************
*** 155,161 ****
  
  asmlinkage int sys_mprotect(unsigned long start, size_t len, unsigned long prot)
  {
! 	unsigned long end;
  	struct vm_area_struct * vma;
  
  	if (start & ~PAGE_MASK)
--- 178,184 ----
  
  asmlinkage int sys_mprotect(unsigned long start, size_t len, unsigned long prot)
  {
! 	unsigned long end, tmp;
  	struct vm_area_struct * vma;
  
  	if (start & ~PAGE_MASK)
***************
*** 188,199 ****
  		if (vma->vm_end >= end)
  			return mprotect_fixup(vma, start, end, newflags);
  
! 		error = mprotect_fixup(vma, start, vma->vm_end, newflags);
  		if (error)
  			return error;
! 		start = vma->vm_end;
! 		vma = vma->vm_next;
! 		if (!vma || vma->vm_start != start)
! 			return -EFAULT;
  	}
  }
--- 211,225 ----
  		if (vma->vm_end >= end)
  			return mprotect_fixup(vma, start, end, newflags);
  
! 		tmp = vma->vm_end;
! 		error = mprotect_fixup(vma, start, tmp, newflags);
  		if (error)
  			return error;
! 		start = tmp;
! 		if (vma->vm_end <= start) {
! 			vma = vma->vm_next;
! 			if (!vma || vma->vm_start != start)
! 				return -EFAULT;
! 		}
  	}
  }