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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20071220192119.0e0472b0.kamezawa.hiroyu@jp.fujitsu.com>
Date:	Thu, 20 Dec 2007 19:21:19 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Balbir Singh <balbir@...ux.vnet.ibm.com>
Cc:	Hugh Dickins <hugh@...itas.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Memory controller use rcu_read_lock() in
 mem_cgroup_cache_charge()

On Thu, 20 Dec 2007 14:31:52 +0530
Balbir Singh <balbir@...ux.vnet.ibm.com> wrote:

> 
> 
> Hugh Dickins noticed that we were using rcu_dereference() without
> rcu_read_lock() in the cache charging routine. The patch below fixes
> this problem
> 
> Signed-off-by: Balbir Singh <balbir@...ux.vnet.ibm.com>
> ---
> 
>  mm/memcontrol.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff -puN mm/memcontrol.c~memory-controller-use-rcu-lead-lock mm/memcontrol.c
> --- linux-2.6.24-rc5/mm/memcontrol.c~memory-controller-use-rcu-lead-lock	2007-12-19 11:52:44.000000000 +0530
> +++ linux-2.6.24-rc5-balbir/mm/memcontrol.c	2007-12-20 14:01:45.000000000 +0530
> @@ -717,16 +717,20 @@ int mem_cgroup_charge(struct page *page,
>  int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
>  				gfp_t gfp_mask)
>  {
> +	int ret = 0;
>  	struct mem_cgroup *mem;
>  	if (!mm)
>  		mm = &init_mm;
>  
> +	rcu_read_lock();
>  	mem = rcu_dereference(mm->mem_cgroup);
> +	css_get(&mem->css);
> +	rcu_read_unlock();
>  	if (mem->control_type == MEM_CGROUP_TYPE_ALL)
> -		return mem_cgroup_charge_common(page, mm, gfp_mask,
> +		ret = mem_cgroup_charge_common(page, mm, gfp_mask,
>  				MEM_CGROUP_CHARGE_TYPE_CACHE);
> -	else
> -		return 0;
> +	css_put(&mem->css);
> +	return ret;
>  }
>  
>  /*
> _
Seems reasonable to me.
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>

Thanks,
-Kame

--
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