]> Git Repo - linux.git/commitdiff
klist: del waiter from klist_remove_waiters before wakeup waitting process
authorwang, biao <[email protected]>
Thu, 16 May 2013 01:50:13 +0000 (09:50 +0800)
committerGreg Kroah-Hartman <[email protected]>
Tue, 21 May 2013 17:16:39 +0000 (10:16 -0700)
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 <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
lib/klist.c

index 0874e41609a6fbf4d786f3b49aa76f85130893f7..358a368a2947057ef9d9309c9dd4fc893523d63d 100644 (file)
@@ -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);
This page took 0.060669 seconds and 4 git commands to generate.