Skip to content
  • rwbarton's avatar
    Treat EPERM error from mmap as an OOM (#7500) · acb91b92
    rwbarton authored and thoughtpolice's avatar thoughtpolice committed
    
    
    Linux can give back EPERM from an mmap call when a user program attempts
    to map pages near `mmap_min_addr`, which is a kernel security measure to
    prevent people from mapping pages at address 0. We may do this when we
    hint to mmap what address to map the pages to.
    
    However, it's theoretically possible we're not actually out of memory -
    we could have continuously mapped pages at some other place far away
    from `mmap_min_addr` and succeeded instead. So as an added precaution,
    if mmap for a given addr gives us EPERM, we'll also attempt to map
    *again*, but without the address hint. Maybe the kernel can do the right
    thing.
    
    However, while testing #7500, the amount of free address space we could
    have otherwise used only turns out to be about 139MB. Which isn't really
    a lot. So, given that, we *also* otherwise treat EPERM as an out of
    memory error.
    
    This fixes #7500.
    
    Signed-off-by: default avatarAustin Seipp <aseipp@pobox.com>
    acb91b92