[PATCH] x86-64: Restore LD_PREFER_MAP_32BIT_EXEC support [BZ #28656]

H.J. Lu hjl.tools@gmail.com
Fri Feb 10 16:50:49 GMT 2023


On Thu, Feb 9, 2023 at 6:35 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > Crossing 2GB boundaries with indirect calls and jumps can use more
> > branch prediction resources on Intel Golden Cove CPU (see the
> > "Misprediction for Branches >2GB" section in Intel 64 and IA-32
> > Architectures Optimization Reference Manual.)  There is visible
> > performance improvement on workloads with many PLT calls when executable
> > and shared libraries are mmapped below 2GB.  Add the Prefer_MAP_32BIT_EXEC
> > bit so that mmap will try to map executable or denywrite pages in shared
> > libraries with MAP_32BIT first.
> >
> > NB: Prefer_MAP_32BIT_EXEC reduces bits available for address space
> > layout randomization (ASLR), which is always disabled for SUID programs
> > and can only be enabled by setting environment variable,
> > LD_PREFER_MAP_32BIT_EXEC.  LD_PREFER_MAP_32BIT_EXEC works only between
> > shared libraries or between shared libraries and executables with
> > addresses below 2GB.  PIEs are usually mapped above 4GB by the kernel.
>
> I still think we should fix this in the kernel, using MAP_DENYWRITE as a
> hint for placement.  This way, it's easier to turn it on unconditionally
> for the whole system because the lower 4 GiB will not be polluted by
> code mappings.
>

Kernel MM change may take a long time and this mitigation may only be needed
for a few specific applications.   On the other hand, it is simpler to
use tunable
instead.

Thanks.

-- 
H.J.


More information about the Libc-alpha mailing list