public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Menage <menage@google.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm] a fixlet for cgroups-make-cgroup_path-rcu-safe.patch
Date: Mon, 22 Dec 2008 09:24:06 +0800	[thread overview]
Message-ID: <494EEC36.8080602@cn.fujitsu.com> (raw)

With cgroups-make-cgroup_path-rcu-safe.patch applied, I can trigger
kernel panic easily using this test program:
	for ((; ;))
	{
		mount -t cgroup -o debug xxx /mnt
		mkdir /mnt/0
		rmdir /mnt/0
		umount /mnt
	}

It's caused by the deactive_super() in rcu callback.

This patch restores the original code that call deactive_super() in
cgroup_diput().

Also remove duplicated comment in cgroup.h added by the patch.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/linux/cgroup.h |    6 ------
 kernel/cgroup.c        |   11 ++++++-----
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/include/linux/cgroup.h.orig b/include/linux/cgroup.h
index 880528d..e267e62 100644
--- a/include/linux/cgroup.h.orig
+++ b/include/linux/cgroup.h
@@ -334,12 +334,6 @@ int cgroup_add_files(struct cgroup *cgrp,
 
 int cgroup_is_removed(const struct cgroup *cgrp);
 
-/*
- * cgroup_path() fills in a filesystem-like path for the given cgroup
- * into "buf", up to "buflen" characters. Should be called with
- * cgroup_mutex held, or else in an RCU section with an RCU-protected
- * cgroup reference
- */
 int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
 
 int cgroup_task_count(const struct cgroup *cgrp);
diff --git a/kernel/cgroup.c.orig b/kernel/cgroup.c
index 5cfd005..d49e97d 100644
--- a/kernel/cgroup.c.orig
+++ b/kernel/cgroup.c
@@ -598,11 +598,6 @@ static void cgroup_call_pre_destroy(struct cgroup *cgrp)
 static void free_cgroup_rcu(struct rcu_head *obj)
 {
 	struct cgroup *cgrp = container_of(obj, struct cgroup, rcu_head);
-	/*
-	 * Drop the active superblock reference that we took when we
-	 * created the cgroup
-	 */
-	deactivate_super(cgrp->root->sb);
 
 	kfree(cgrp);
 }
@@ -632,6 +627,12 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
 		cgrp->root->number_of_cgroups--;
 		mutex_unlock(&cgroup_mutex);
 
+		/*
+		 * Drop the active superblock reference that we took when we
+		 * created the cgroup
+		 */
+		deactivate_super(cgrp->root->sb);
+
 		call_rcu(&cgrp->rcu_head, free_cgroup_rcu);
 	}
 	iput(inode);


                 reply	other threads:[~2008-12-22  1:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=494EEC36.8080602@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox