From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756854Ab0FONYK (ORCPT ); Tue, 15 Jun 2010 09:24:10 -0400 Received: from gir.skynet.ie ([193.1.99.77]:36247 "EHLO gir.skynet.ie" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755935Ab0FONYI (ORCPT ); Tue, 15 Jun 2010 09:24:08 -0400 Date: Tue, 15 Jun 2010 14:23:50 +0100 From: Mel Gorman To: Nick Piggin Cc: Andrew Morton , Rik van Riel , Dave Chinner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Chris Mason , Johannes Weiner , Christoph Hellwig , KAMEZAWA Hiroyuki Subject: Re: [patch] mm: vmscan fix mapping use after free Message-ID: <20100615132349.GI26788@csn.ul.ie> References: <1276514273-27693-12-git-send-email-mel@csn.ul.ie> <20100614231144.GG6590@dastard> <20100614162143.04783749.akpm@linux-foundation.org> <20100615003943.GK6590@dastard> <4C16D46D.3020302@redhat.com> <20100614184544.32b1c371.akpm@linux-foundation.org> <4C16FCAE.4050607@redhat.com> <20100614213732.034b4a13.akpm@linux-foundation.org> <20100615051242.GD6138@laptop> <20100615054343.GE6138@laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20100615054343.GE6138@laptop> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2010 at 03:43:44PM +1000, Nick Piggin wrote: > On Tue, Jun 15, 2010 at 03:12:42PM +1000, Nick Piggin wrote: > > > Once that page is unlocked, we can't touch *mapping - its inode can be > > > concurrently reclaimed. Although I guess the technique in > > > handle_write_error() can be reused. > > > > Nasty. That guy needs to be using lock_page_nosync(). > -- > > Need lock_page_nosync here because we have no reference to the mapping when > taking the page lock. > > Signed-off-by: Nick Piggin > Thanks, I've picked this up and merged it into the series and removed the "hand grenade" comment. > --- > mm/vmscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/mm/vmscan.c > =================================================================== > --- linux-2.6.orig/mm/vmscan.c > +++ linux-2.6/mm/vmscan.c > @@ -296,7 +296,7 @@ static int may_write_to_queue(struct bac > static void handle_write_error(struct address_space *mapping, > struct page *page, int error) > { > - lock_page(page); > + lock_page_nosync(page); > if (page_mapping(page) == mapping) > mapping_set_error(mapping, error); > unlock_page(page); > -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mel Gorman Subject: Re: [patch] mm: vmscan fix mapping use after free Date: Tue, 15 Jun 2010 14:23:50 +0100 Message-ID: <20100615132349.GI26788@csn.ul.ie> References: <1276514273-27693-12-git-send-email-mel@csn.ul.ie> <20100614231144.GG6590@dastard> <20100614162143.04783749.akpm@linux-foundation.org> <20100615003943.GK6590@dastard> <4C16D46D.3020302@redhat.com> <20100614184544.32b1c371.akpm@linux-foundation.org> <4C16FCAE.4050607@redhat.com> <20100614213732.034b4a13.akpm@linux-foundation.org> <20100615051242.GD6138@laptop> <20100615054343.GE6138@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Cc: Andrew Morton , Rik van Riel , Dave Chinner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Chris Mason , Johannes Weiner , Christoph Hellwig , KAMEZAWA Hiroyuki To: Nick Piggin Return-path: Content-Disposition: inline In-Reply-To: <20100615054343.GE6138@laptop> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Tue, Jun 15, 2010 at 03:43:44PM +1000, Nick Piggin wrote: > On Tue, Jun 15, 2010 at 03:12:42PM +1000, Nick Piggin wrote: > > > Once that page is unlocked, we can't touch *mapping - its inode can be > > > concurrently reclaimed. Although I guess the technique in > > > handle_write_error() can be reused. > > > > Nasty. That guy needs to be using lock_page_nosync(). > -- > > Need lock_page_nosync here because we have no reference to the mapping when > taking the page lock. > > Signed-off-by: Nick Piggin > Thanks, I've picked this up and merged it into the series and removed the "hand grenade" comment. > --- > mm/vmscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/mm/vmscan.c > =================================================================== > --- linux-2.6.orig/mm/vmscan.c > +++ linux-2.6/mm/vmscan.c > @@ -296,7 +296,7 @@ static int may_write_to_queue(struct bac > static void handle_write_error(struct address_space *mapping, > struct page *page, int error) > { > - lock_page(page); > + lock_page_nosync(page); > if (page_mapping(page) == mapping) > mapping_set_error(mapping, error); > unlock_page(page); > -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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: email@kvack.org