public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] x86-64: Restore LD_PREFER_MAP_32BIT_EXEC support [BZ #28656]
Date: Fri, 10 Feb 2023 16:54:24 -0500	[thread overview]
Message-ID: <202f0385-86bd-fa4a-3a44-804d9d01ecaf@redhat.com> (raw)
In-Reply-To: <CAMe9rOq3hCABsc9b63OZHd5u27F-r9gsE9HrrbteaTDr70DrMA@mail.gmail.com>

On 2/10/23 11:50, H.J. Lu wrote:
> 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.

I tend to agree with you here that a Kernel MM change is going to take too long and may
be possibly fragile.

I would like to see this use a tunable with an alias.

Note that the Linux man pages continue to document LD_PREFER_MAP_32BIT_EXEC :-)

-- 
Cheers,
Carlos.


  reply	other threads:[~2023-02-10 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 17:22 H.J. Lu
2023-02-09 14:35 ` Florian Weimer
2023-02-10 16:50   ` H.J. Lu
2023-02-10 21:54     ` Carlos O'Donell [this message]
2023-02-10 22:22       ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2022-08-01 19:51 H.J. Lu
2022-08-02  8:00 ` Florian Weimer
2022-08-05 21:53   ` H.J. Lu
2022-08-08 13:29     ` Florian Weimer
2022-08-08 17:02       ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202f0385-86bd-fa4a-3a44-804d9d01ecaf@redhat.com \
    --to=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).