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:	Thu, 6 Jan 2011 11:51:20 +0900
From:	Minchan Kim <minchan.kim@...il.com>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	Daisuke Nishimura <nishimura@....nes.nec.co.jp>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	LKML <linux-kernel@...r.kernel.org>,
	linux-mm <linux-mm@...ck.org>
Subject: Re: [BUGFIX][PATCH] memcg: fix memory migration of shmem swapcache

On Thu, Jan 6, 2011 at 9:52 AM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@...fujitsu.com> wrote:
> On Wed, 5 Jan 2011 15:47:48 +0900
> Daisuke Nishimura <nishimura@....nes.nec.co.jp> wrote:
>
>> On Wed, 5 Jan 2011 13:48:50 +0900
>> Minchan Kim <minchan.kim@...il.com> wrote:
>>
>> > Hi,
>> >
>> > On Wed, Jan 5, 2011 at 1:00 PM, Daisuke Nishimura
>> > <nishimura@....nes.nec.co.jp> wrote:
>> > > Hi.
>> > >
>> > > This is a fix for a problem which has bothered me for a month.
>> > >
>> > > ===
>> > > From: Daisuke Nishimura <nishimura@....nes.nec.co.jp>
>> > >
>> > > In current implimentation, mem_cgroup_end_migration() decides whether the page
>> > > migration has succeeded or not by checking "oldpage->mapping".
>> > >
>> > > But if we are tring to migrate a shmem swapcache, the page->mapping of it is
>> > > NULL from the begining, so the check would be invalid.
>> > > As a result, mem_cgroup_end_migration() assumes the migration has succeeded
>> > > even if it's not, so "newpage" would be freed while it's not uncharged.
>> > >
>> > > This patch fixes it by passing mem_cgroup_end_migration() the result of the
>> > > page migration.
>> > >
>> > > Signed-off-by: Daisuke Nishimura <nishimura@....nes.nec.co.jp>
>> > Reviewed-by: Minchan Kim <minchan.kim@...il.com>
>> >
>> > Nice catch. I don't oppose the patch.
>> Thank you for your review.
>>
>
> Nice catch.
>
>
>> > But as looking the code in unmap_and_move, I feel part of mem cgroup
>> > migrate is rather awkward.
>> >
>> > int unmap_and_move()
>> > {
>> >    charge = mem_cgroup_prepare_migration(xxx);
>> >    ..
>> >    BUG_ON(charge); <-- BUG if it is charged?
>> >    ..
>> > uncharge:
>> >    if (!charge)    <-- why do we have to uncharge !charge?
>> >       mem_group_end_migration(xxx);
>> >    ..
>> > }
>> >
>> > 'charge' local variable isn't good. How about changing "uncharge" or whatever?
>> hmm, I agree that current code seems a bit confusing, but I can't think of
>> better name to imply the result of 'charge'.
>>
>> And considering more, I can't understand why we need to check "if (!charge)"
>> before mem_cgroup_end_migration() becase it must be always true and, IMHO,
>> mem_cgroup_end_migration() should do all necesarry checks to avoid double uncharge.
>
> ok, please remove it.
> Before this commit, http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=01b1ae63c2270cbacfd43fea94578c17950eb548;hp=bced0520fe462bb94021dcabd32e99630c171be2
>
> "mem" is not passed as argument and this was the reason for the vairable "charge".
>
> We can check "charge is in moving" by checking "mem == NULL".

I will send the patch after Andrew picks Daisuke's patch up.
Thanks.

-- 
Kind regards,
Minchan Kim
--
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