public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Vasiliy Kulikov <segoon@openwall.com>
Cc: Balbir Singh <bsingharora@gmail.com>,
	Jerome Marchand <jmarchan@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] taskstats: add_del_listener() should ignore !valid listener's
Date: Wed, 20 Jul 2011 21:00:36 +0200	[thread overview]
Message-ID: <20110720190036.GB21753@redhat.com> (raw)
In-Reply-To: <20110720185959.GA21749@redhat.com>

When send_cpu_listeners() finds the orphaned listener it marks
it as !valid and drops listeners->sem. Before it takes this sem
for wrinting, 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>
---

 kernel/taskstats.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- ts/kernel/taskstats.c~2_ck_valid	2011-07-20 20:18:19.000000000 +0200
+++ ts/kernel/taskstats.c	2011-07-20 20:18:47.000000000 +0200
@@ -304,7 +304,7 @@ static int add_del_listener(pid_t pid, c
 			listeners = &per_cpu(listener_array, cpu);
 			down_write(&listeners->sem);
 			list_for_each_entry(s2, &listeners->list, list) {
-				if (s2->pid == pid)
+				if (s2->pid == pid && s2->valid)
 					goto exists;
 			}
 			list_add(&s->list, &listeners->list);


  parent reply	other threads:[~2011-07-20 19:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 18:59 [PATCH 0/2] 26c4caea "don't allow duplicate entries in listener mode" fix Oleg Nesterov
2011-07-20 19:00 ` [PATCH 1/2] taskstats: add_del_listener() shouldn't use the wrong node Oleg Nesterov
2011-07-20 19:50   ` Vasiliy Kulikov
2011-07-21 12:28   ` Jerome Marchand
2011-07-20 19:00 ` Oleg Nesterov [this message]
2011-07-20 19:46   ` [PATCH 2/2] taskstats: add_del_listener() should ignore !valid listener's Vasiliy Kulikov
2011-07-20 21:01     ` Oleg Nesterov
2011-07-21 12:50       ` Vasiliy Kulikov
2011-07-21 14:29         ` Oleg Nesterov
2011-07-21 15:49   ` Balbir Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110720190036.GB21753@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsingharora@gmail.com \
    --cc=jmarchan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segoon@openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox