From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-Id: <20130911042917.861283797@goodmis.org> Date: Wed, 11 Sep 2013 00:29:40 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Li Zefan , Tejun Heo Subject: [153/251] cgroup: fix umount vs cgroup_cfts_commit() race References: <20130911042707.738353451@goodmis.org> Content-Disposition: inline; filename=0153-cgroup-fix-umount-vs-cgroup_cfts_commit-race.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: 3.6.11.9-rc1 stable review patch. If anyone has any objections, please let me know. ------------------ From: Li Zefan [ Upstream commit 084457f284abf6789d90509ee11dae383842b23b ] cgroup_cfts_commit() uses dget() to keep cgroup alive after cgroup_mutex is dropped, but dget() won't prevent cgroupfs from being umounted. When the race happens, vfs will see some dentries with non-zero refcnt while umount is in process. Keep running this: mount -t cgroup -o blkio xxx /cgroup umount /cgroup And this: modprobe cfq-iosched rmmod cfs-iosched After a while, the BUG() in shrink_dcache_for_umount_subtree() may be triggered: BUG: Dentry xxx{i=0,n=blkio.yyy} still in use (1) [umount of cgroup cgroup] Signed-off-by: Li Zefan Signed-off-by: Tejun Heo Cc: stable@vger.kernel.org Signed-off-by: Steven Rostedt --- kernel/cgroup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 9cf9102..79e528f 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2761,13 +2761,17 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss, { LIST_HEAD(pending); struct cgroup *cgrp, *n; + struct super_block *sb = ss->root->sb; /* %NULL @cfts indicates abort and don't bother if @ss isn't attached */ - if (cfts && ss->root != &rootnode) { + if (cfts && ss->root != &rootnode && + atomic_inc_not_zero(&sb->s_active)) { list_for_each_entry(cgrp, &ss->root->allcg_list, allcg_node) { dget(cgrp->dentry); list_add_tail(&cgrp->cft_q_node, &pending); } + } else { + sb = NULL; } mutex_unlock(&cgroup_mutex); @@ -2790,6 +2794,9 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss, dput(cgrp->dentry); } + if (sb) + deactivate_super(sb); + mutex_unlock(&cgroup_cft_mutex); } -- 1.7.10.4