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]
Date:	Mon, 24 Jan 2011 11:45:10 +0100
From:	Johannes Weiner <hannes@...xchg.org>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"nishimura@....nes.nec.co.jp" <nishimura@....nes.nec.co.jp>,
	"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
	"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/7] memcg : comment, style fixes for recent patch of
 move_parent

On Mon, Jan 24, 2011 at 07:15:35PM +0900, KAMEZAWA Hiroyuki wrote:
> On Mon, 24 Jan 2011 11:14:02 +0100
> Johannes Weiner <hannes@...xchg.org> wrote:
> 
> > On Fri, Jan 21, 2011 at 03:37:26PM +0900, KAMEZAWA Hiroyuki wrote:
> > > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> > > 
> > > A fix for 987eba66e0e6aa654d60881a14731a353ee0acb4
> > > 
> > > A clean up for mem_cgroup_move_parent(). 
> > >  - remove unnecessary initialization of local variable.
> > >  - rename charge_size -> page_size
> > >  - remove unnecessary (wrong) comment.
> > > 
> > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> > > ---
> > >  mm/memcontrol.c |   17 +++++++++--------
> > >  1 file changed, 9 insertions(+), 8 deletions(-)
> > > 
> > > Index: mmotm-0107/mm/memcontrol.c
> > > ===================================================================
> > > --- mmotm-0107.orig/mm/memcontrol.c
> > > +++ mmotm-0107/mm/memcontrol.c
> > > @@ -2265,7 +2265,7 @@ static int mem_cgroup_move_parent(struct
> > >  	struct cgroup *cg = child->css.cgroup;
> > >  	struct cgroup *pcg = cg->parent;
> > >  	struct mem_cgroup *parent;
> > > -	int charge = PAGE_SIZE;
> > > +	int page_size;
> > >  	unsigned long flags;
> > >  	int ret;
> > >  
> > > @@ -2278,22 +2278,23 @@ static int mem_cgroup_move_parent(struct
> > >  		goto out;
> > >  	if (isolate_lru_page(page))
> > >  		goto put;
> > > -	/* The page is isolated from LRU and we have no race with splitting */
> > > -	charge = PAGE_SIZE << compound_order(page);
> > > +
> > > +	page_size = PAGE_SIZE << compound_order(page);
> > 
> > Okay, so you remove the wrong comment, but that does not make the code
> > right.  What protects compound_order from reading garbage because the
> > page is currently splitting?
> > 
> 
> ==
> static int mem_cgroup_move_account(struct page_cgroup *pc,
>                 struct mem_cgroup *from, struct mem_cgroup *to,
>                 bool uncharge, int charge_size)
> {
>         int ret = -EINVAL;
>         unsigned long flags;
> 
>         if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page))
>                 return -EBUSY;
> ==
> 
> This is called under compound_lock(). Then, if someone breaks THP,
> -EBUSY and retry.

This charge_size contains exactly the garbage you just read from an
unprotected compound_order().  It could be anything if the page is
split concurrently.
--
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