linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm: fix madvise infinine loop
@ 2007-03-10  3:49 Nick Piggin
  2007-03-15 19:49 ` Hugh Dickins
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Piggin @ 2007-03-10  3:49 UTC (permalink / raw)
  To: Andrew Morton, Badari Pulavarty; +Cc: Linux Memory Management List

Hi,

This has been noticed when running a particular database server which I
won't name. Please apply.

--
madvise(MADV_REMOVE) can go into an infinite loop or cause an oops if
the call covers a region from the start of a vma, and extending past that
vma.

Signed-off-by: Nick Piggin <npiggin@suse.de>

Index: linux-2.6.16/mm/madvise.c
===================================================================
--- linux-2.6.16.orig/mm/madvise.c
+++ linux-2.6.16/mm/madvise.c
@@ -155,11 +155,14 @@ static long madvise_dontneed(struct vm_a
  * Other filesystems return -ENOSYS.
  */
 static long madvise_remove(struct vm_area_struct *vma,
+				struct vm_area_struct **prev,
 				unsigned long start, unsigned long end)
 {
 	struct address_space *mapping;
         loff_t offset, endoff;
 
+	*prev = vma;
+
 	if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB))
 		return -EINVAL;
 
@@ -199,7 +202,7 @@ madvise_vma(struct vm_area_struct *vma, 
 		error = madvise_behavior(vma, prev, start, end, behavior);
 		break;
 	case MADV_REMOVE:
-		error = madvise_remove(vma, start, end);
+		error = madvise_remove(vma, prev, start, end);
 		break;
 
 	case MADV_WILLNEED:

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2007-03-15 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-10  3:49 [patch] mm: fix madvise infinine loop Nick Piggin
2007-03-15 19:49 ` Hugh Dickins

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