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, 19 Nov 2012 17:02:42 +0800
From:	Li Zefan <lizefan@...wei.com>
To:	Tejun Heo <tj@...nel.org>
CC:	<containers@...ts.linux-foundation.org>, <cgroups@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <mhocko@...e.cz>,
	<glommer@...allels.com>
Subject: Re: [PATCH 06/17] cgroup: remove duplicate RCU free on struct cgroup

On 2012/11/13 11:01, Tejun Heo wrote:
> struct cgroup is made RCU-safe by synchronize_rcu() in cgroup_diput().

but synchronize_rcu() is called before ss->destroy().

rcu_read_lock();
for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq)
	print_cfs_rq(m, cpu, cfs_rq);
	-> call cgroup_path(task_group->css.cgroup);
rcu_read_unlock();

With this patch, if the above code race with cgroup_diput(), we might
end up accessing a cgroup which has been freed.

> There is no reason to use RCU safe kfree on it after it.  Remove
> cgroup->rcu_head and use kfree() instead of kfree_rcu() in
> cgroup_diput().
> 
> Signed-off-by: Tejun Heo <tj@...nel.org>
> ---
>  include/linux/cgroup.h | 3 ---
>  kernel/cgroup.c        | 2 +-
>  2 files changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index d605857..9dcbfa1 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -196,9 +196,6 @@ struct cgroup {
>  	struct list_head pidlists;
>  	struct mutex pidlist_mutex;
>  
> -	/* For RCU-protected deletion */
> -	struct rcu_head rcu_head;
> -
>  	/* List of events which userspace want to receive */
>  	struct list_head event_list;
>  	spinlock_t event_list_lock;
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 278752e..a91e7ad 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -893,7 +893,7 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
>  
>  		simple_xattrs_free(&cgrp->xattrs);
>  
> -		kfree_rcu(cgrp, rcu_head);
> +		kfree(cgrp);

This was also added to prevent a race in group scheduling code, and I think the race still
exists.



>  	} else {
>  		struct cfent *cfe = __d_cfe(dentry);
>  		struct cgroup *cgrp = dentry->d_parent->d_fsdata;
> 

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