diff mbox

[3.8.y.z,extended,stable] Patch "klist: del waiter from klist_remove_waiters before wakeup waitting" has been added to staging queue

Message ID 1372198799-17919-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa June 25, 2013, 10:19 p.m. UTC
This is a note to let you know that I have just added a patch titled

    klist: del waiter from klist_remove_waiters before wakeup waitting

to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.8.y-queue

This patch is scheduled to be released in version 3.8.13.4.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.8.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

From 0fa262dd46295da1dc52740a9b62ef7e81f2e756 Mon Sep 17 00:00:00 2001
From: "wang, biao" <biao.wang@intel.com>
Date: Thu, 16 May 2013 09:50:13 +0800
Subject: 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 lib/klist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
1.8.1.2
diff mbox

Patch

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)
 			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);