summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorwang, biao <biao.wang@intel.com>2013-05-16 09:50:13 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-07 12:46:36 -0700
commit929b30b9d3f530900c6e3176b1cf29fbcf307e25 (patch)
tree71f022ee09002b282599f9db07abf6cb2011bfb6 /lib
parentc0872911a5926b9c0a3e570cf8bf2a027275a664 (diff)
klist: del waiter from klist_remove_waiters before wakeup waitting process
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/klist.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/klist.c b/lib/klist.c
index 573d6068a42e..d0b4b18d17a6 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -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);