unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan D." <jan.h.d@swipnet.se>
Cc: emacs-devel@gnu.org
Subject: Re: `exec shield' test in configure too strict?
Date: Thu, 7 Oct 2004 20:16:33 +0200	[thread overview]
Message-ID: <05038177-188D-11D9-821D-000D93505B76@swipnet.se> (raw)
In-Reply-To: <E1CFbNW-0004jx-SN@fencepost.gnu.org>


>     Doesn't this harm cross-building Emacs?  I always thought that 
> running
>     a test program at configure time should be avoided, and that tests
>     that only compile or link programs should be peferred.
>
> Yes, that is true.  But maybe there is no way to test this
> based on the compilation environment.

As far as I know there isn't, the kernel controls this.  If the 
personality
of the process is PER_LINUX at startup and exec-shield is enabled, the
randomizing of the heap start address is done by the kernel.

>
>     When cross compiling the test obviously can not be run, so 
> configure
>     assumes
>     that the heap start address is not random.  Come to think of it, 
> the old
>     test (checking /proc/sys/kernel/exec-shield) was worse, as it did 
> not
>     handle
>     cross compiling.
>
> That will be right most of the time today, but that may not be
> true in the future.
>
> Can we modify unexec to handle this case correctly?  What exactly is
> it that we now do in the case where we see that exec shield is
> enabled?  How does that avoid the problem?

We can modify unexec I think.  Currently it memcpy:s the area from
data start to sbrk(0) (heap end) into the new data area.  But since 
there
is a hole between BSS and heap start, an invalid memory range is 
accessed
and we get a core dump:

      temacs                           Emacs
   ----------------------         ------------------
   | Data               |         |                |
   ----------------------         |                |
   | BSS                |         |                |
   ----------------------  =====> |     Data       |
   | 128-192 Mbyte hole |         |                |
   ----------------------         |                |
   | Heap               |         |                |
   ----------------------         ------------------

We could either just skip the hole and seek over it in the new data 
area,
but then the Emacs binary would be large, as the 128-192 Mbyte is added 
to
the Emacs binary size, but it has no purpose.  Another possibility is to
make a new data ELF section that contains the copied heap, and has the
correct address.  If this is feasible I don't really know, but I think
it is (I am not an ELF expert).

I previously thought that malloc needed modification, but apparently
it can handle the new hole between Emacs data and the new random heap
start address (Emacs has a zero sized BSS).

Currently we run temacs like this
% setarch i386 ./temacs ...

setarch changes personality to PER_LINUX32 and then runs temacs.  temacs
inherits the changed personality, so the kernel does not randomize the 
heap
start address.

	Jan D.

  reply	other threads:[~2004-10-07 18:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-04  5:53 `exec shield' test in configure too strict? Miles Bader
2004-10-04 15:04 ` Jan D.
2004-10-04 21:20   ` Miles Bader
2004-10-04 21:37     ` Jan D.
2004-10-05 20:40     ` Jan D.
2004-10-05 21:44       ` Stefan Monnier
2004-10-05 22:11         ` Jan D.
2004-10-06  0:18           ` Stefan
2004-10-06  1:34             ` Miles Bader
2004-10-06  7:50               ` Jan D.
2004-10-06  7:56                 ` Miles Bader
2004-10-06 11:31                   ` Jan D.
2004-10-06  7:48             ` Jan D.
2004-10-06 12:58               ` Stefan Monnier
2004-10-06 11:16       ` Eli Zaretskii
2004-10-06 11:38         ` Jan D.
2004-10-07 15:44           ` Camm Maguire
2004-10-07 16:44         ` Richard Stallman
2004-10-07 18:16           ` Jan D. [this message]
2004-10-09  1:25             ` Richard Stallman
2004-10-11 10:30               ` Jan D.
2004-10-12  8:56                 ` Richard Stallman
2004-10-20 20:33                   ` Jan D.
2004-10-21 13:57                     ` Richard Stallman
2004-10-22 21:02                     ` Camm Maguire
2004-10-25 19:05                       ` Jan D.
2004-10-26 20:24                         ` Camm Maguire
2004-10-27 10:48                         ` Richard Stallman
2004-10-27 12:17                           ` Jan D.
2004-11-06 17:00                     ` other unexec problems Camm Maguire
2004-11-09  7:58                       ` Jan D.
2004-10-05 18:04 ` `exec shield' test in configure too strict? Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=05038177-188D-11D9-821D-000D93505B76@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).