[30/93] klist: del waiter from klist_remove_waiters before wakeup waitting process

Submitted by Luis Henriques on June 18, 2013, 11:42 a.m.


Message ID 1371555821-12820-31-git-send-email-luis.henriques@canonical.com
State New
Headers show

Commit Message

Luis Henriques June 18, 2013, 11:42 a.m. -stable review patch.  If anyone has any objections, please let me know.


From: "wang, biao" <biao.wang@intel.com>

commit ac5a2962b02f57dea76d314ef2521a2170b28ab6 upstream.

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.

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>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
 lib/klist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/lib/klist.c b/lib/klist.c
index 0874e41..358a368 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -193,10 +193,10 @@  static void klist_release(struct kref *kref)
 		if (waiter->node != n)
+		list_del(&waiter->list);
 		waiter->woken = 1;
-		list_del(&waiter->list);
 	knode_set_klist(n, NULL);