[patch 45/58] mm: check for no mmaps in exit_mmap()

From: Greg KH
Date: Wed Apr 29 2009 - 18:38:59 EST


2.6.27-stable review patch. If anyone has any objections, please let us know.

------------------

From: Johannes Weiner <hannes@xxxxxxxxxxx>

commit dcd4a049b9751828c516c59709f3fdf50436df85 upstream.

When dup_mmap() ooms we can end up with mm->mmap == NULL. The error
path does mmput() and unmap_vmas() gets a NULL vma which it
dereferences.

In exit_mmap() there is nothing to do at all for this case, we can
cancel the callpath right there.

[akpm@xxxxxxxxxxxxxxxxxxxx: add sorely-needed comment]
Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
Reported-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
Cc: Nick Piggin <nickpiggin@xxxxxxxxxxxx>
Cc: Hugh Dickins <hugh@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Reported-by: Kir Kolyshkin <kir@xxxxxxxxxx>
Tested-by: Kir Kolyshkin <kir@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
mm/mmap.c | 3 +++
1 file changed, 3 insertions(+)

--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2068,6 +2068,9 @@ void exit_mmap(struct mm_struct *mm)
arch_exit_mmap(mm);
mmu_notifier_release(mm);

+ if (!mm->mmap) /* Can happen if dup_mmap() received an OOM */
+ return;
+
lru_add_drain();
flush_cache_mm(mm);
tlb = tlb_gather_mmu(mm, 1);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/