Skip to content

Commit

Permalink
klist: del waiter from klist_remove_waiters before wakeup waitting pr…
Browse files Browse the repository at this point in the history
…ocess

There is a race between klist_remove and klist_release. klist_remove
uses a local var waiter saved on stack. When klist_release calls
wake_up_process(waiter->process) to wake up the waiter, waiter might run
immediately and reuse the stack. Then, klist_release calls
list_del(&waiter->list) to change previous
wait data and cause prior waiter thread corrupt.

The patch fixes it against kernel 3.9.

Change-Id: I3c418c9ca5411a8ba934322172e33b93d6a480bb
Signed-off-by: wang, biao <biao.wang@intel.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: ac5a2962b02f57dea76d314ef2521a2170b28ab6
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
  • Loading branch information
wang, biao authored and Matt Wagantall committed Oct 20, 2013
1 parent ce64606 commit c7bd62a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/klist.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ static void klist_release(struct kref *kref)
if (waiter->node != n)
continue;

list_del(&waiter->list);
waiter->woken = 1;
mb();
wake_up_process(waiter->process);
list_del(&waiter->list);
}
spin_unlock(&klist_remove_lock);
knode_set_klist(n, NULL);
Expand Down

0 comments on commit c7bd62a

Please sign in to comment.