From: wangbiao <biao.wang@intel.com>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
mingo@redhat.com, peterz@infradead.org
Cc: biao.wang@intel.com, yanmin.zhang@intel.com
Subject: [PATCH] klist: del waiter from klist_remove_waiters before wakeup waitting process
Date: Fri, 03 May 2013 15:06:36 +0800 [thread overview]
Message-ID: <1367564796.27529.15.camel@wangbiao> (raw)
From: "wang, biao" <biao.wang@intel.com>
Date: Fri, 3 May 2013 14:18:34 +0800
Subject: [PATCH] klist: del waiter from klist_remove_waiters before wakeup
waitting process
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>
---
lib/klist.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
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);
--
1.7.6
next reply other threads:[~2013-05-03 7:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 7:06 wangbiao [this message]
2013-05-03 10:42 ` [PATCH] klist: del waiter from klist_remove_waiters before wakeup waitting process Peter Zijlstra
2013-05-07 8:49 ` Zhang, Yanmin
-- strict thread matches above, loose matches on Subject: below --
2013-05-16 1:50 wangbiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367564796.27529.15.camel@wangbiao \
--to=biao.wang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yanmin.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.