Skip to content

Commit

Permalink
net: pktgen: fix race between pktgen_thread_worker() and kthread_stop()
Browse files Browse the repository at this point in the history
[ Upstream commit fecdf8b ]

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 <[email protected]>
Reported-by: Jan Stancek <[email protected]>
Reported-by: Marcelo Leitner <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
oleg-nesterov authored and sashalevin committed Sep 27, 2015
1 parent 4192b62 commit d69e9e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d69e9e1

Please sign in to comment.