From: Oleg Nesterov <oleg@redhat.com>
To: Alexei Starovoitov <ast@plumgrid.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>
Cc: Jan Stancek <jstancek@redhat.com>,
Marcelo Leitner <mleitner@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] net: pktgen: fix race between pktgen_thread_worker() and kthread_stop()
Date: Wed, 8 Jul 2015 21:42:11 +0200 [thread overview]
Message-ID: <20150708194211.GA26552@redhat.com> (raw)
In-Reply-To: <20150708194154.GA26534@redhat.com>
pktgen_thread_worker() is obviously racy, kthread_stop() can come
between the kthread_should_stop() check and set_current_state().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Jan Stancek <jstancek@redhat.com>
Reported-by: Marcelo Leitner <mleitner@redhat.com>
---
net/core/pktgen.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 508155b..043ea18 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3490,8 +3490,10 @@ static int pktgen_thread_worker(void *arg)
pktgen_rem_thread(t);
/* Wait for kthread_stop */
- while (!kthread_should_stop()) {
+ for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
+ if (kthread_should_stop())
+ break;
schedule();
}
__set_current_state(TASK_RUNNING);
--
1.5.5.1
next prev parent reply other threads:[~2015-07-08 19:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 19:41 [PATCH 0/2] net: pktgen: fix race between pktgen_thread_worker() and kthread_stop() Oleg Nesterov
2015-07-08 19:42 ` Oleg Nesterov [this message]
2015-07-08 19:42 ` [PATCH 2/2] net: pktgen: kill the "Wait for kthread_stop" code in pktgen_thread_worker() Oleg Nesterov
2015-07-09 22:06 ` [PATCH 0/2] net: pktgen: fix race between pktgen_thread_worker() and kthread_stop() David Miller
2015-07-10 11:32 ` Marcelo Ricardo Leitner
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=20150708194211.GA26552@redhat.com \
--to=oleg@redhat.com \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jstancek@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mleitner@redhat.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).