cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
PATCH 1/1 cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
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.
---
kernel/cpuset.c +5 -1
@@ -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)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Lai Jiangshan
task_cs()callscgroup_subsys_state().
You man "calls task_subsys_state()"
Quoted 6 lines
we must use
rcu_read_lock()to protectcgroup_subsys_state().in
current_cpuset_is_being_rebound(), we don't dereference to task_cs()'s return value, buttask_cs()accessescss_set, thiscss_setmaybe freed whentask_cs()called.
Wouldn't this be fixed by your patch that adds an rcu_read_lock() to task_subsys_state() ?
Paul
Quoted 22 lines
Signed-off-by Lai Jiangshan <[email protected]>---
kernel/cpuset.c +5
-1@@ -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)
Quoted 2 lines · Lai Jiangshan
task_cs()callscgroup_subsys_state().
You man "calls task_subsys_state()"
Quoted 6 lines
we must use
rcu_read_lock()to protectcgroup_subsys_state().in
current_cpuset_is_being_rebound(), we don't dereference to task_cs()'s return value, buttask_cs()accessescss_set, thiscss_setmaybe freed whentask_cs()called.
Wouldn't this be fixed by your patch that adds an rcu_read_lock() to task_subsys_state() ?
Paul
Quoted 22 lines
Signed-off-by Lai Jiangshan <[email protected]>---
kernel/cpuset.c +5
-1@@ -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)
A message that is not in the archive (sent off-list or not yet received): 6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 4 lines · Paul Menage
Wouldn't this be fixed by your patch that adds an
rcu_read_lock()totask_subsys_state()?
Sorry, your other patch actually adds the rcu_read_lock() to task_cgroup(). But adding an rcu_read_lock() to task_subsys_state() would also help here.
Paul
Quoted 4 lines · Paul Menage
Wouldn't this be fixed by your patch that adds an
rcu_read_lock()totask_subsys_state()?
Sorry, your other patch actually adds the rcu_read_lock() to task_cgroup(). But adding an rcu_read_lock() to task_subsys_state() would also help here.
Paul
A message that is not in the archive (sent off-list or not yet received): 6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 8 lines · Paul Menage
Quoted 3 lines · Paul Menage
Wouldn't this be fixed by your patch that adds an
rcu_read_lock()totask_subsys_state()?Sorry, your other patch actually adds the
rcu_read_lock()totask_cgroup(). But adding anrcu_read_lock()totask_subsys_state()would also help here.
Adding an rcu_read_lock() to task_subsys_state() also help here. But task_subsys_state() is used in fast path.
If we add an implicit rcu_read_lock() in task_subsys_state(), we still need rcu_read_lock()/task_lock() for using it,
so it's redundant rcu_read_lock(), and slower the fast path a little.
Lai.
Quoted 8 lines · Paul Menage
Quoted 3 lines · Paul Menage
Wouldn't this be fixed by your patch that adds an
rcu_read_lock()totask_subsys_state()?Sorry, your other patch actually adds the
rcu_read_lock()totask_cgroup(). But adding anrcu_read_lock()totask_subsys_state()would also help here.
Adding an rcu_read_lock() to task_subsys_state() also help here. But task_subsys_state() is used in fast path.
If we add an implicit rcu_read_lock() in task_subsys_state(), we still need rcu_read_lock()/task_lock() for using it,
so it's redundant rcu_read_lock(), and slower the fast path a little.
Lai.