From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761707AbZD2Wi6 (ORCPT ); Wed, 29 Apr 2009 18:38:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759966AbZD2WVu (ORCPT ); Wed, 29 Apr 2009 18:21:50 -0400 Received: from kroah.org ([198.145.64.141]:40674 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760061AbZD2WVp (ORCPT ); Wed, 29 Apr 2009 18:21:45 -0400 X-Mailbox-Line: From gregkh@mini.kroah.org Wed Apr 29 15:09:29 2009 Message-Id: <20090429220929.694765675@mini.kroah.org> User-Agent: quilt/0.48-1 Date: Wed, 29 Apr 2009 15:07:44 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Johannes Weiner , Nick Piggin , Hugh Dickins Subject: [patch 45/58] mm: check for no mmaps in exit_mmap() References: <20090429220659.339950874@mini.kroah.org> Content-Disposition: inline; filename=mm-check-for-no-mmaps-in-exit_mmap.patch In-Reply-To: <20090429221657.GA11765@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2.6.27-stable review patch. If anyone has any objections, please let us know. ------------------ From: Johannes Weiner 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@linux-foundation.org: add sorely-needed comment] Signed-off-by: Johannes Weiner Reported-by: Akinobu Mita Cc: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Reported-by: Kir Kolyshkin Tested-by: Kir Kolyshkin Signed-off-by: Greg Kroah-Hartman --- 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);