lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110120212841.GB9506@random.random>
Date:	Thu, 20 Jan 2011 22:28:41 +0100
From:	Andrea Arcangeli <aarcange@...hat.com>
To:	Christoph Lameter <cl@...ux.com>
Cc:	Minchan Kim <minchan.kim@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-mm <linux-mm@...ck.org>,
	LKML <linux-kernel@...r.kernel.org>, Mel Gorman <mel@....ul.ie>
Subject: Re: [PATCH 1/3] When migrate_pages returns 0, all pages must have
 been released

On Thu, Jan 20, 2011 at 12:49:15PM -0600, Christoph Lameter wrote:
> On Thu, 20 Jan 2011, Andrea Arcangeli wrote:
> 
> > Hello,
> >
> > On Thu, Jan 20, 2011 at 11:30:35AM -0600, Christoph Lameter wrote:
> > > On Fri, 21 Jan 2011, Minchan Kim wrote:
> > >
> > > > diff --git a/mm/migrate.c b/mm/migrate.c
> > > > index 46fe8cc..7d34237 100644
> > > > --- a/mm/migrate.c
> > > > +++ b/mm/migrate.c
> > > > @@ -772,6 +772,7 @@ uncharge:
> > > >  unlock:
> > > >  	unlock_page(page);
> > > >
> > > > +move_newpage:
> > > >  	if (rc != -EAGAIN) {
> > > >   		/*
> > > >   		 * A page that has been migrated has all references
> > > > @@ -785,8 +786,6 @@ unlock:
> > > >  		putback_lru_page(page);
> > > >  	}
> > > >
> > > > -move_newpage:
> > > > -
> > > >  	/*
> > > >  	 * Move the new page to the LRU. If migration was not successful
> > > >  	 * then this will free the page.
> > > >
> > >
> > > What does this do? Not covered by the description.
> >
> > It makes a difference for the two goto move_newpage, when rc =
> > 0. Otherwise the function will return 0, despite
> > putback_lru_page(page) wasn't called (and the caller of migrate_pages
> > won't call putback_lru_pages if migrate_pages returned 0).
> 
> Think about the difference:
> 
> Moving the move_newpage will now cause another removal and freeing of the
> page if rc != -EAGAIN.

The only ones doing "goto move_newpage" after the first two memleaks
that are fixed by this patch are always run with rc = -EAGAIN. So this
makes a difference only for the first two which were leaking memory before.

> The first goto move_newpage (because page count is 1) will now mean that
> the page is freed twice. One because of the rc != EAGAIN branch and then
> another time by the following putback_lru_page().

Which following putback_lru_page()?  You mean
putback_lru_page(newpage)? That is for the newly allocated page
(allocated at the very top, so always needed), it's not relevant to
the page_count(page) = 1. The page_count 1 is hold by the caller, so
it's leaking memory right now (for everything but compaction).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ