aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-08-03 19:21:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-03 20:25:20 -0400
commita7295898a1d2e501427f557111c2b4bdfc90b1ed (patch)
tree143ce6e69d8aa795494120a00c62ca0ade8bac40 /kernel
parentdfc428b656c4693a2334a8d9865b430beddb562a (diff)
taskstats: add_del_listener() should ignore !valid listeners
When send_cpu_listeners() finds the orphaned listener it marks it as !valid and drops listeners->sem. Before it takes this sem for writing, s->pid can be reused and add_del_listener() can wrongly try to re-use this entry. Change add_del_listener() to check ->valid = T. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Vasiliy Kulikov <segoon@openwall.com> Acked-by: Balbir Singh <bsingharora@gmail.com> Cc: Jerome Marchand <jmarchan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/taskstats.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index a09a54936f19..e19ce1454ee1 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -304,7 +304,7 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
304 listeners = &per_cpu(listener_array, cpu); 304 listeners = &per_cpu(listener_array, cpu);
305 down_write(&listeners->sem); 305 down_write(&listeners->sem);
306 list_for_each_entry(s2, &listeners->list, list) { 306 list_for_each_entry(s2, &listeners->list, list) {
307 if (s2->pid == pid) 307 if (s2->pid == pid && s2->valid)
308 goto exists; 308 goto exists;
309 } 309 }
310 list_add(&s->list, &listeners->list); 310 list_add(&s->list, &listeners->list);