Skip to content
  • Linus Torvalds's avatar
    elf: don't use MAP_FIXED_NOREPLACE for elf executable mappings · b212921b
    Linus Torvalds authored
    In commit 4ed28639 ("fs, elf: drop MAP_FIXED usage from elf_map") we
    changed elf to use MAP_FIXED_NOREPLACE instead of MAP_FIXED for the
    executable mappings.
    
    Then, people reported that it broke some binaries that had overlapping
    segments from the same file, and commit ad55eac7 ("elf: enforce
    MAP_FIXED on overlaying elf segments") re-instated MAP_FIXED for some
    overlaying elf segment cases.  But only some - despite the summary line
    of that commit, it only did it when it also does a temporary brk vma for
    one obvious overlapping case.
    
    Now Russell King reports another overlapping case with old 32-bit x86
    binaries, which doesn't trigger that limited case.  End result: we had
    better just drop MAP_FIXED_NOREPLACE entirely, and go back to MAP_FIXED.
    
    Yes, it's a sign of old binaries generated with old tool-chains, but we
    do pride ourselves on not breaking existing setups.
    
    This still leaves MAP_FIXED_NOREPLACE in place for the load_elf_inter...
    b212921b