public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Topi Miettinen <toiwoton@gmail.com>, libc-alpha@sourceware.org
Subject: Re: Randomize offset between program segments?
Date: Wed, 21 Oct 2020 07:51:32 +0530	[thread overview]
Message-ID: <e56acd8c-5c18-5e0c-25d5-56e9e15c3e72@gotplt.org> (raw)
In-Reply-To: <f7ce6a45-358e-f024-def3-ef3c223a241e@gmail.com>

On 10/19/20 9:01 PM, Topi Miettinen via Libc-alpha wrote:
> I'd like to improve address space randomization (ASLR) by randomizing
> the offset between .text, .data and .bss segments (or more generalized,
> any program segments). With large code generation model (-mcmodel=large)
> on AMD64, the offset could be very large, but even with the default
> model, the segments could be randomized within range of RIP-relative
> accesses (+/-2GB). Currently the dynamic loader can't randomize the
> segments (nothing also tells it if this would be OK) so it maps them
> next to each other, which is predictable and boring.

What is the advantage of randomizing offsets between these segments?

> For this to happen, I think the compiler would have to emit relocations
> for all cross-segment accesses and probably flagging the shared object
> somehow. Then, when detecting the flag, the dynamic loader could load
> the segments at random offsets within 2GB, or if the large model was
> used in compilation (another flag), anywhere in the available virtual
> address space (let OS map the segment anywhere by using mmap(NULL,...)).

The challenge is not just pc-relative range, but also technical
feasibility of using pc-relative loads in the first place because the
change would either involve an additional indirection during load (like
GOT) which could have a significant performance overhead or a text
relocation, which would be like inviting wolves to drive out raccoons.

Of course, first we need to determine if there are raccoons.

Siddhesh

  reply	other threads:[~2020-10-21  2:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 15:31 Topi Miettinen
2020-10-21  2:21 ` Siddhesh Poyarekar [this message]
2020-10-21  7:40   ` Topi Miettinen
2020-10-21  9:14     ` Siddhesh Poyarekar
2020-10-21  9:34       ` Topi Miettinen
2020-10-21  9:54         ` Siddhesh Poyarekar
2020-10-21 10:44           ` Topi Miettinen
2020-10-29  8:04             ` Siddhesh Poyarekar
2020-10-30 15:37               ` Topi Miettinen
2020-10-21  5:33 ` Florian Weimer
2020-10-21  8:02   ` Topi Miettinen
2020-10-21  8:06     ` Florian Weimer
2020-10-21  9:28       ` Topi Miettinen

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=e56acd8c-5c18-5e0c-25d5-56e9e15c3e72@gotplt.org \
    --to=siddhesh@gotplt.org \
    --cc=libc-alpha@sourceware.org \
    --cc=toiwoton@gmail.com \
    /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).