* [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
[not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-11-21 19:05 ` Paul Menage
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[parent not found: <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>]
* Re: [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
[not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2008-11-21 19:05 ` Paul Menage
0 siblings, 0 replies; 8+ messages in thread
From: Paul Menage @ 2008-11-21 19:05 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Linux Containers, Andrew Morton, Linux Kernel Mailing List
On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:
>
> task_cs() calls cgroup_subsys_state().
You man "calls task_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.
Wouldn't this be fixed by your patch that adds an rcu_read_lock() to
task_subsys_state() ?
Paul
>
> 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 [flat|nested] 8+ messages in thread
* Re: [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 [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value Lai Jiangshan
[not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2008-11-21 19:05 ` Paul Menage
[not found] ` <6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-21 19:07 ` Paul Menage
1 sibling, 2 replies; 8+ messages in thread
From: Paul Menage @ 2008-11-21 19:05 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Andrew Morton, Linux Kernel Mailing List, Linux Containers
On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
>
> task_cs() calls cgroup_subsys_state().
You man "calls task_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.
Wouldn't this be fixed by your patch that adds an rcu_read_lock() to
task_subsys_state() ?
Paul
>
> 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 [flat|nested] 8+ messages in thread[parent not found: <6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
2008-11-21 19:05 ` Paul Menage
[not found] ` <6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-11-21 19:07 ` Paul Menage
[not found] ` <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-22 3:01 ` Lai Jiangshan
1 sibling, 2 replies; 8+ messages in thread
From: Paul Menage @ 2008-11-21 19:07 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Andrew Morton, Linux Kernel Mailing List, Linux Containers
On Fri, Nov 21, 2008 at 11:05 AM, Paul Menage <menage@google.com> wrote:
>
> Wouldn't this be fixed by your patch that adds an rcu_read_lock() to
> task_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
^ permalink raw reply [flat|nested] 8+ messages in thread[parent not found: <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
[not found] ` <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-11-22 3:01 ` Lai Jiangshan
0 siblings, 0 replies; 8+ messages in thread
From: Lai Jiangshan @ 2008-11-22 3:01 UTC (permalink / raw)
To: Paul Menage; +Cc: Linux Containers, Andrew Morton, Linux Kernel Mailing List
Paul Menage wrote:
> On Fri, Nov 21, 2008 at 11:05 AM, Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
>> Wouldn't this be fixed by your patch that adds an rcu_read_lock() to
>> task_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.
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] cpuset: rcu_read_lock() to protect task_cs() even we don't dereference to task_cs()'s return value
2008-11-21 19:07 ` Paul Menage
[not found] ` <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-11-22 3:01 ` Lai Jiangshan
1 sibling, 0 replies; 8+ messages in thread
From: Lai Jiangshan @ 2008-11-22 3:01 UTC (permalink / raw)
To: Paul Menage; +Cc: Andrew Morton, Linux Kernel Mailing List, Linux Containers
Paul Menage wrote:
> On Fri, Nov 21, 2008 at 11:05 AM, Paul Menage <menage@google.com> wrote:
>> Wouldn't this be fixed by your patch that adds an rcu_read_lock() to
>> task_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.
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.
^ permalink raw reply [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
[not found] ` <49267624.70305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-11-21 19:05 ` Paul Menage
2008-11-21 19:05 ` Paul Menage
[not found] ` <6599ad830811211105p711aebc3v85ffffbc399bdd6e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-21 19:07 ` Paul Menage
2008-11-21 19:07 ` Paul Menage
[not found] ` <6599ad830811211107n141e6cb5n2abf14e59110d764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-22 3:01 ` Lai Jiangshan
2008-11-22 3:01 ` Lai Jiangshan
-- 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.