mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrey Ryabinin <a.ryabinin@samsung.com>,
	Dave Jones <davej@codemonkey.org.uk>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: sched: memory corruption on completing completions
Date: Wed, 4 Feb 2015 15:46:18 -0800	[thread overview]
Message-ID: <20150204154618.36511661ab558c0a9e047a77@linux-foundation.org> (raw)
In-Reply-To: <54D2AA16.6030706@oracle.com>

On Wed, 04 Feb 2015 18:24:06 -0500 Sasha Levin <sasha.levin@oracle.com> wrote:

> Hi all,
> 
> I was fuzzing with trinity on a -next kernel with the KASan patchset, and
> got what initially appeared to be a rather odd trace:
> 
> ...
>
> 
> I now have a theory for why it happens:
> 
> Thread A				Thread B
> ----------------------------------------------------------
> 
> [Enter function]
> DECLARE_COMPLETION_ONSTACK(x)
> wait_for_completion(x)
> 					complete(x)
> 					[In complete(x):]
> 				        spin_lock_irqsave(&x->wait.lock, flags);
> 				        x->done++;
> 				        __wake_up_locked(&x->wait, TASK_NORMAL, 1);
> [Done waiting, wakes up]
> [Exit function]
> 				        spin_unlock_irqrestore(&x->wait.lock, flags);
> 
> 
> 
> So the spin_unlock_irqrestore() at the end of complete() would proceed to corruption
> the stack of thread A.

But wait_for_completion() takes ->wait.lock as well, which should
provide the needed synchronization (__wait_for_common,
do_wait_for_common).  I'm not seeing a hole in the logic, but it looks
like there might be one.

  reply	other threads:[~2015-02-04 23:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 23:24 Sasha Levin
2015-02-04 23:46 ` Andrew Morton [this message]
2015-02-05  0:16 ` Linus Torvalds
2015-02-05  7:10   ` Ingo Molnar
2015-02-05  9:30   ` Peter Zijlstra
2015-02-05 20:44     ` Sasha Levin
2015-02-05 20:59   ` Davidlohr Bueso
2015-02-05 21:02     ` Sasha Levin
2015-02-05 21:34       ` Linus Torvalds
2015-02-05 22:37         ` Davidlohr Bueso
2015-02-05 22:57           ` Linus Torvalds
2015-02-06  6:48             ` Raghavendra K T
2015-02-06 15:00               ` Raghavendra K T
2015-02-06 12:29           ` Raghavendra K T

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=20150204154618.36511661ab558c0a9e047a77@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.ryabinin@samsung.com \
    --cc=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sasha.levin@oracle.com \
    --cc=torvalds@linux-foundation.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®