linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: kkourt@cslab.ece.ntua.gr
Cc: bkk@cslab.ece.ntua.gr, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-numa@vger.kernel.org
Subject: Re: [BUG] Invalid return address of mmap() followed by mbind() in multithreaded context
Date: Tue, 28 Jun 2011 11:06:29 +0900	[thread overview]
Message-ID: <4E093725.7010002@jp.fujitsu.com> (raw)
In-Reply-To: <20110627171842.GA7554@solar.cslab.ece.ntua.gr>

(2011/06/28 2:18), Kornilios Kourtis wrote:
> 
> Hi,
> 
> On Fri, Jun 17, 2011 at 06:21:49PM +0300, Vasileios Karakasis wrote:
>> Hi,
>>
>> I am implementing a multithreaded numa aware code where each thread
>> mmap()'s an anonymous private region and then mbind()'s it to its local
>> node. The threads are performing a series of such mmap() + mbind()
>> operations. My program crashed with SIGSEGV and I noticed that mmap()
>> returned an invalid address.
> 
> I've taken a closer look at this issue.
> 
> As Vasileios said, it can be reproduced by having two threads doing the
> following loop:
> | for {
> | 	addr = mmap(4096, MAP_ANONUMOUS)
> | 	if (addr == (void *)-1)
> | 		continue
> | 	mbind(addr, 4096, 0x1) // do mbind on first NUMA node
> | }
> After a couple of iterations, mbind() will return EFAULT, although the addr is
> valid.
> 
> Doing a bisect, pins it down to the following commit (Author added to To:):
> 	9d8cebd4bcd7c3878462fdfda34bbcdeb4df7ef4
> 	mm: fix mbind vma merge problem
> Which adds merging of vmas in the mbind() path.
> Reverting this commit, seems to fix the issue.
> 
> I 've added some printks to track down the issue, and EFAULT is returned on:
> mm/mempolicy.c: mbind_range()
> |   vma = find_vma_prev(mm. start, &prev);
> |   if (!vma |vma->vm_start > start)
> |       return EFAULT;
> Where: vma->start > start
> 
> I am not sure what exactly happens, but concurrent merges and splits
> of (already mapped) VMAs do not seem to work well together.

Hi

Thank you for digging this! I look it at soon as far as possible.

 - kosaki

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2011-06-28  2:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 15:21 Vasileios Karakasis
2011-06-18 18:12 ` Andi Kleen
2011-06-18 18:41   ` Vasileios Karakasis
2011-06-19 23:42     ` Vasileios Karakasis
2011-06-27 17:18 ` Kornilios Kourtis
2011-06-28  2:06   ` KOSAKI Motohiro [this message]

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=4E093725.7010002@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=bkk@cslab.ece.ntua.gr \
    --cc=kkourt@cslab.ece.ntua.gr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-numa@vger.kernel.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