linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] cgroup: Fix an RCU warning in cgroup_path()
@ 2010-04-22  9:29 Li Zefan
  2010-04-22  9:30 ` [PATCH 2/5] cgroup: Fix an RCU warning in alloc_css_id() Li Zefan
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Li Zefan @ 2010-04-22  9:29 UTC (permalink / raw)
  To: LKML
  Cc: containers@lists.osdl.org, Paul E. McKenney, Paul Menage,
	Andrew Morton

with CONFIG_PROVE_RCU=y, a warning can be triggered:

  # mount -t cgroup -o debug xxx /mnt
  # cat /proc/$$/cgroup

...
kernel/cgroup.c:1649 invoked rcu_dereference_check() without protection!
...

This is a false-positive, because cgroup_path() can be called
with either rcu_read_lock() held or cgroup_mutex held.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e2769e1..4ca928d 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1646,7 +1646,9 @@ static inline struct cftype *__d_cft(struct dentry *dentry)
 int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
 {
 	char *start;
-	struct dentry *dentry = rcu_dereference(cgrp->dentry);
+	struct dentry *dentry = rcu_dereference_check(cgrp->dentry,
+						      rcu_read_lock_held() ||
+						      cgroup_lock_is_held());
 
 	if (!dentry || cgrp == dummytop) {
 		/*
@@ -1662,13 +1664,17 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
 	*--start = '\0';
 	for (;;) {
 		int len = dentry->d_name.len;
+
 		if ((start -= len) < buf)
 			return -ENAMETOOLONG;
-		memcpy(start, cgrp->dentry->d_name.name, len);
+		memcpy(start, dentry->d_name.name, len);
 		cgrp = cgrp->parent;
 		if (!cgrp)
 			break;
-		dentry = rcu_dereference(cgrp->dentry);
+
+		dentry = rcu_dereference_check(cgrp->dentry,
+					       rcu_read_lock_held() ||
+					       cgroup_lock_is_held());
 		if (!cgrp->parent)
 			continue;
 		if (--start < buf)
-- 
1.6.3


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-05-07 14:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22  9:29 [PATCH 1/5] cgroup: Fix an RCU warning in cgroup_path() Li Zefan
2010-04-22  9:30 ` [PATCH 2/5] cgroup: Fix an RCU warning in alloc_css_id() Li Zefan
2010-04-22 19:55   ` Paul E. McKenney
2010-04-22  9:30 ` [PATCH 3/5] sched: Fix an RCU warning in print_task() Li Zefan
2010-04-22 10:20   ` Peter Zijlstra
2010-04-22 21:12     ` Matt Helsley
2010-04-22 22:05       ` Paul E. McKenney
2010-04-22 19:56   ` Paul E. McKenney
2010-04-22  9:31 ` [PATCH 4/5] freezer cgroup: Fix an RCU warning in cgroup_freezing_or_frozen() Li Zefan
2010-04-22 12:27   ` Peter Zijlstra
2010-04-22 19:59     ` Paul E. McKenney
2010-04-22 20:08       ` Peter Zijlstra
2010-04-23  1:05         ` Li Zefan
2010-04-23  6:47           ` Peter Zijlstra
2010-04-22  9:32 ` [PATCH 5/5] blk-cgroup: Fix an RCU warning in blkiocg_create() Li Zefan
2010-04-22 14:31   ` Vivek Goyal
2010-04-22 19:57   ` Paul E. McKenney
2010-05-07  6:56     ` Li Zefan
2010-05-07  6:57       ` Jens Axboe
2010-05-07 14:55         ` Paul E. McKenney
2010-04-22 19:55 ` [PATCH 1/5] cgroup: Fix an RCU warning in cgroup_path() Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).