unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Ulrich Mueller <ulm@gentoo.org>, Andreas Schwab <schwab@linux-m68k.org>
Cc: emacs-devel@gnu.org
Subject: Re: Size of emacs.pdmp changes between successive installs
Date: Tue, 19 Nov 2019 18:27:32 -0800	[thread overview]
Message-ID: <3984229f-b4e1-c347-a378-6f44d53bfc60@cs.ucla.edu> (raw)
In-Reply-To: <w6ga78rl9bw.fsf@kph.uni-mainz.de>

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

>> Only when unexecing.

> Right, with this trivial patch I'm getting a reproducible size
> of emacs.pdmp, too:

Thanks to both of you. I installed the attached, which does something 
similar and simplifies the code a bit too.

[-- Attachment #2: 0001-Make-.pdmp-file-more-reproducible.patch --]
[-- Type: text/x-patch, Size: 2873 bytes --]

From 9ac586928bbef16b572bcb34bfcbcb5515c2335a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 19 Nov 2019 18:23:01 -0800
Subject: [PATCH] Make .pdmp file more reproducible
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Ulrich Müller
<https://lists.gnu.org/r/emacs-devel/2019-11/msg00757.html>
and diagnosed by Andreas Schwab
<https://lists.gnu.org/r/emacs-devel/2019-11/msg00774.html>.
* src/sysdep.c (maybe_disable_address_randomization):
Disable ASLR if any kind of dumping, instead of merely if
unexec dumping.  Omit first arg for simplicity; all uses changed.
---
 src/emacs.c  | 3 +--
 src/lisp.h   | 4 ++--
 src/sysdep.c | 7 +++++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index 21a05d337e..8a6e34deda 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1054,8 +1054,7 @@ main (int argc, char **argv)
     load_pdump (argc, argv);
 #endif
 
-  argc = maybe_disable_address_randomization (
-    will_dump_with_unexec_p (), argc, argv);
+  argc = maybe_disable_address_randomization (argc, argv);
 
 #if defined GNU_LINUX && defined HAVE_UNEXEC
   if (!initialized)
diff --git a/src/lisp.h b/src/lisp.h
index 1d25add928..e0ae2c4262 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4576,10 +4576,10 @@ #define DAEMON_RUNNING (w32_daemon_event != INVALID_HANDLE_VALUE)
 
 /* Defined in sysdep.c.  */
 #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
-extern int maybe_disable_address_randomization (bool, int, char **);
+extern int maybe_disable_address_randomization (int, char **);
 #else
 INLINE int
-maybe_disable_address_randomization (bool dumping, int argc, char **argv)
+maybe_disable_address_randomization (int argc, char **argv)
 {
   return argc;
 }
diff --git a/src/sysdep.c b/src/sysdep.c
index aa18ee22fd..e34ab2eb58 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -158,14 +158,17 @@ #define ULLONG_MAX TYPE_MAXIMUM (unsigned long long int)
 /* Try to disable randomization if the current process needs it and
    does not appear to have it already.  */
 int
-maybe_disable_address_randomization (bool dumping, int argc, char **argv)
+maybe_disable_address_randomization (int argc, char **argv)
 {
   /* Undocumented Emacs option used only by this function.  */
   static char const aslr_disabled_option[] = "--__aslr-disabled";
 
   if (argc < 2 || strcmp (argv[1], aslr_disabled_option) != 0)
     {
-      bool disable_aslr = dumping;
+      /* If dumping via unexec, ASLR must be disabled, as otherwise
+	 data may be scattered and undumpable as a simple executable.
+	 If pdumping, disabling ASLR makes the .pdmp file reproducible.  */
+      bool disable_aslr = will_dump_p ();
 # ifdef __PPC64__
       disable_aslr = true;
 # endif
-- 
2.23.0


  reply	other threads:[~2019-11-20  2:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 16:59 Size of emacs.pdmp changes between successive installs Ulrich Mueller
2019-11-19 17:18 ` Paul Eggert
2019-11-19 17:45 ` Eli Zaretskii
2019-11-19 18:19   ` Andreas Schwab
2019-11-19 18:16 ` Andreas Schwab
2019-11-19 20:56   ` Paul Eggert
2019-11-19 22:14     ` Andreas Schwab
2019-11-19 23:45       ` Ulrich Mueller
2019-11-20  2:27         ` Paul Eggert [this message]
2019-11-20 11:55           ` Andreas Schwab
2019-11-20 19:54             ` Paul Eggert
2019-11-20 19:59               ` Paul Eggert
2019-11-20  9:29         ` Andreas Schwab
2019-11-20 11:42           ` Ulrich Mueller
2019-11-19 23:21   ` Ulrich Mueller

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=3984229f-b4e1-c347-a378-6f44d53bfc60@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@linux-m68k.org \
    --cc=ulm@gentoo.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).