From: Peter Zijlstra <peterz@infradead.org>
To: wangbiao <biao.wang@intel.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
mingo@redhat.com, yanmin.zhang@intel.com,
mochel@digitalimplant.org
Subject: Re: [PATCH] klist: del waiter from klist_remove_waiters before wakeup waitting process
Date: Fri, 3 May 2013 12:42:08 +0200 [thread overview]
Message-ID: <20130503104207.GA27558@dyad.programming.kicks-ass.net> (raw)
In-Reply-To: <1367564796.27529.15.camel@wangbiao>
On Fri, May 03, 2013 at 03:06:36PM +0800, wangbiao wrote:
> 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.
I've never seen that code before in my life; but after a quick look you appear
to be completely right.
> Signed-off-by: wang, biao <biao.wang@intel.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> 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 prev parent reply other threads:[~2013-05-03 10:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 7:06 [PATCH] klist: del waiter from klist_remove_waiters before wakeup waitting process wangbiao
2013-05-03 10:42 ` Peter Zijlstra [this message]
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=20130503104207.GA27558@dyad.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=biao.wang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mochel@digitalimplant.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox