All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
@ 2008-11-21  8:49 Lai Jiangshan
  2008-11-21 19:05 ` Paul Menage
       [not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Lai Jiangshan @ 2008-11-21  8:49 UTC (permalink / raw)
  To: Andrew Morton, Paul Menage, Linux Kernel Mailing List,
	Linux Containers


task_cs() calls cgroup_subsys_state().

we must use rcu_read_lock() to protect cgroup_subsys_state().

in current_cpuset_is_being_rebound(), we don't dereference to task_cs()'s
return value, but task_cs() accesses css_set, this css_set maybe freed
when task_cs() called.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 3e00526..e0e087e 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1141,7 +1136,11 @@ done:
 
 int current_cpuset_is_being_rebound(void)
 {
-	return task_cs(current) == cpuset_being_rebound;
+	struct cpuset *cs;
+	rcu_read_lock();
+	cs = task_cs(current);
+	rcu_read_unlock();
+	return cs == cpuset_being_rebound;
 }
 
 static int update_relax_domain_level(struct cpuset *cs, s64 val)


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
@ 2008-11-21  8:49 Lai Jiangshan
  0 siblings, 0 replies; 8+ messages in thread
From: Lai Jiangshan @ 2008-11-21  8:49 UTC (permalink / raw)
  To: Andrew Morton, Paul Menage, Linux Kernel Mailing List,
	Linux Containers


task_cs() calls cgroup_subsys_state().

we must use rcu_read_lock() to protect cgroup_subsys_state().

in current_cpuset_is_being_rebound(), we don't dereference to task_cs()'s
return value, but task_cs() accesses css_set, this css_set maybe freed
when task_cs() called.

Signed-off-by: Lai Jiangshan <laijs-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 3e00526..e0e087e 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1141,7 +1136,11 @@ done:
 
 int current_cpuset_is_being_rebound(void)
 {
-	return task_cs(current) == cpuset_being_rebound;
+	struct cpuset *cs;
+	rcu_read_lock();
+	cs = task_cs(current);
+	rcu_read_unlock();
+	return cs == cpuset_being_rebound;
 }
 
 static int update_relax_domain_level(struct cpuset *cs, s64 val)

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

end of thread, other threads:[~2008-11-22  3:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21  8:49 [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value Lai Jiangshan
2008-11-21 19:05 ` Paul Menage
2008-11-21 19:07   ` Paul Menage
2008-11-22  3:01     ` Lai Jiangshan
     [not found]     ` <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-22  3:01       ` Lai Jiangshan
     [not found]   ` <6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-21 19:07     ` Paul Menage
     [not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-11-21 19:05   ` Paul Menage
  -- strict thread matches above, loose matches on Subject: below --
2008-11-21  8:49 Lai Jiangshan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.