Re: [BUG] Invalid return address of mmap() followed by mbind() in multithreaded context

Vasileios Karakasis <[email protected]> Sat, 18 Jun 2011 21:41:03 +0300
Newsgroups org.kernel.vger.linux-numa,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
That's right, but what I want to demonstrate is that the address
returned by mmap() is invalid and the dereference crashes the program,
while it shouldn't. I could equally omit this statement, in which case
mbind() would fail with EFAULT.

On 06/18/2011 09:12 PM, Andi Kleen wrote:
>>     for (i = 0; i < NR_ITER; i++) {
>>         addr = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE,
>>                     MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
>>         if (addr == (void *) -1) {
>>             assert(0 && "mmap failed");
>>         }
>>         *addr = 0;
>>
>>         err = mbind(addr, PAGE_SIZE, MPOL_BIND, &node, sizeof(node), 0);
> 
> mbind() can be only done before the first touch. you're not actually testing 
> numa policy.
> 
> -andi

-- 
V.K.
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk388U0ACgkQHUHhfRemepxHwwCg8nBwl3ZuVdCmwEecizOdDuOM
680An3lRmAFNS5Ek8ZQjBSPb5YUcqNwA
=CacT
-----END PGP SIGNATURE-----