mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhang, Yanmin" <yanmin.zhang@intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
	"Wang, Biao" <biao.wang@intel.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"mochel@digitalimplant.org" <mochel@digitalimplant.org>
Subject: RE: [PATCH] klist: del waiter from klist_remove_waiters before wakeup waitting process
Date: Tue, 7 May 2013 08:49:54 +0000	[thread overview]
Message-ID: <144086DDB7BB6D429C79280EB1C804D409CE3BAC@SHSMSX102.ccr.corp.intel.com> (raw)
In-Reply-To: <20130503104207.GA27558@dyad.programming.kicks-ass.net>

Andrew,

Would you like to merge the patch to your MM tree?

Yanmin

>-----Original Message-----
>From: Peter Zijlstra [mailto:peterz@infradead.org]
>Sent: Friday, May 03, 2013 6:42 PM
>To: Wang, Biao
>Cc: akpm@linux-foundation.org; linux-kernel@vger.kernel.org;
>mingo@redhat.com; Zhang, Yanmin; mochel@digitalimplant.org
>Subject: Re: [PATCH] klist: del waiter from klist_remove_waiters before wakeup
>waitting process
>
>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
>>
>>
>>

  reply	other threads:[~2013-05-07  8:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03  7:06 wangbiao
2013-05-03 10:42 ` Peter Zijlstra
2013-05-07  8:49   ` Zhang, Yanmin [this message]
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=144086DDB7BB6D429C79280EB1C804D409CE3BAC@SHSMSX102.ccr.corp.intel.com \
    --to=yanmin.zhang@intel.com \
    --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=peterz@infradead.org \
    /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

all inboxes | Powered by JetHome®