Re: [PATCH] mm: don't clobber partially overlapping VMA with MAP_FIXED_NOREPLACE

From: Michael Ellerman
Date: Fri Oct 12 2018 - 06:23:29 EST


Jann Horn <jannh@xxxxxxxxxx> writes:
> On Wed, Oct 10, 2018 at 7:19 PM Michal Hocko <mhocko@xxxxxxxx> wrote:
>> On Wed 10-10-18 17:27:36, Jann Horn wrote:
>> > Daniel Micay reports that attempting to use MAP_FIXED_NOREPLACE in an
>> > application causes that application to randomly crash. The existing check
>> > for handling MAP_FIXED_NOREPLACE looks up the first VMA that either
>> > overlaps or follows the requested region, and then bails out if that VMA
>> > overlaps *the start* of the requested region. It does not bail out if the
>> > VMA only overlaps another part of the requested region.
>>
>> I do not understand. Could you give me an example?
>
> Sure.
>
> =======
> user@debian:~$ cat mmap_fixed_simple.c
> #include <sys/mman.h>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>

..

Mind if I turn that into a selftest?

cheers