diff options
| author | Paul Eggert | 2019-11-19 18:23:01 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-11-19 18:27:10 -0800 |
| commit | 0fce8e9391fd107f9267188a36b85aea778b8440 (patch) | |
| tree | ea60f601124ee5c232a44912057255de78a6d19b /src | |
| parent | aa79f4e8c635537c50a50db211542c0f41443ae2 (diff) | |
| download | emacs-0fce8e9391fd107f9267188a36b85aea778b8440.tar.gz emacs-0fce8e9391fd107f9267188a36b85aea778b8440.zip | |
Make .pdmp file more reproducible
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 3 | ||||
| -rw-r--r-- | src/lisp.h | 4 | ||||
| -rw-r--r-- | src/sysdep.c | 7 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/emacs.c b/src/emacs.c index 21a05d337ef..8a6e34deda7 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1054,8 +1054,7 @@ main (int argc, char **argv) | |||
| 1054 | load_pdump (argc, argv); | 1054 | load_pdump (argc, argv); |
| 1055 | #endif | 1055 | #endif |
| 1056 | 1056 | ||
| 1057 | argc = maybe_disable_address_randomization ( | 1057 | argc = maybe_disable_address_randomization (argc, argv); |
| 1058 | will_dump_with_unexec_p (), argc, argv); | ||
| 1059 | 1058 | ||
| 1060 | #if defined GNU_LINUX && defined HAVE_UNEXEC | 1059 | #if defined GNU_LINUX && defined HAVE_UNEXEC |
| 1061 | if (!initialized) | 1060 | if (!initialized) |
diff --git a/src/lisp.h b/src/lisp.h index 1d25add9287..e0ae2c4262d 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4576,10 +4576,10 @@ struct tty_display_info; | |||
| 4576 | 4576 | ||
| 4577 | /* Defined in sysdep.c. */ | 4577 | /* Defined in sysdep.c. */ |
| 4578 | #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE | 4578 | #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE |
| 4579 | extern int maybe_disable_address_randomization (bool, int, char **); | 4579 | extern int maybe_disable_address_randomization (int, char **); |
| 4580 | #else | 4580 | #else |
| 4581 | INLINE int | 4581 | INLINE int |
| 4582 | maybe_disable_address_randomization (bool dumping, int argc, char **argv) | 4582 | maybe_disable_address_randomization (int argc, char **argv) |
| 4583 | { | 4583 | { |
| 4584 | return argc; | 4584 | return argc; |
| 4585 | } | 4585 | } |
diff --git a/src/sysdep.c b/src/sysdep.c index aa18ee22fd5..e34ab2eb587 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -158,14 +158,17 @@ static int exec_personality; | |||
| 158 | /* Try to disable randomization if the current process needs it and | 158 | /* Try to disable randomization if the current process needs it and |
| 159 | does not appear to have it already. */ | 159 | does not appear to have it already. */ |
| 160 | int | 160 | int |
| 161 | maybe_disable_address_randomization (bool dumping, int argc, char **argv) | 161 | maybe_disable_address_randomization (int argc, char **argv) |
| 162 | { | 162 | { |
| 163 | /* Undocumented Emacs option used only by this function. */ | 163 | /* Undocumented Emacs option used only by this function. */ |
| 164 | static char const aslr_disabled_option[] = "--__aslr-disabled"; | 164 | static char const aslr_disabled_option[] = "--__aslr-disabled"; |
| 165 | 165 | ||
| 166 | if (argc < 2 || strcmp (argv[1], aslr_disabled_option) != 0) | 166 | if (argc < 2 || strcmp (argv[1], aslr_disabled_option) != 0) |
| 167 | { | 167 | { |
| 168 | bool disable_aslr = dumping; | 168 | /* If dumping via unexec, ASLR must be disabled, as otherwise |
| 169 | data may be scattered and undumpable as a simple executable. | ||
| 170 | If pdumping, disabling ASLR makes the .pdmp file reproducible. */ | ||
| 171 | bool disable_aslr = will_dump_p (); | ||
| 169 | # ifdef __PPC64__ | 172 | # ifdef __PPC64__ |
| 170 | disable_aslr = true; | 173 | disable_aslr = true; |
| 171 | # endif | 174 | # endif |