From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Size of emacs.pdmp changes between successive installs Date: Tue, 19 Nov 2019 18:27:32 -0800 Organization: UCLA Computer Science Department Message-ID: <3984229f-b4e1-c347-a378-6f44d53bfc60@cs.ucla.edu> References: <871ru34tq0.fsf@igel.home> <87o8x7344g.fsf@igel.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------456187E57C14723A555D0D5A" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="45369"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 Cc: emacs-devel@gnu.org To: Ulrich Mueller , Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 20 03:27:58 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iXFio-000BdQ-FL for ged-emacs-devel@m.gmane.org; Wed, 20 Nov 2019 03:27:58 +0100 Original-Received: from localhost ([::1]:53170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXFin-00073D-Bq for ged-emacs-devel@m.gmane.org; Tue, 19 Nov 2019 21:27:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59226) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXFiY-0006tJ-Fi for emacs-devel@gnu.org; Tue, 19 Nov 2019 21:27:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXFiW-00063b-Fp for emacs-devel@gnu.org; Tue, 19 Nov 2019 21:27:42 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59566) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXFiU-0005yE-9v for emacs-devel@gnu.org; Tue, 19 Nov 2019 21:27:40 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D483B160059; Tue, 19 Nov 2019 18:27:33 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GOTLIfLvzJDj; Tue, 19 Nov 2019 18:27:32 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C6AEC160082; Tue, 19 Nov 2019 18:27:32 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id V0Cei2WhcOjW; Tue, 19 Nov 2019 18:27:32 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id A4EBD160059; Tue, 19 Nov 2019 18:27:32 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:242459 Archived-At: This is a multi-part message in MIME format. --------------456187E57C14723A555D0D5A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit >> 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. --------------456187E57C14723A555D0D5A Content-Type: text/x-patch; charset=UTF-8; name="0001-Make-.pdmp-file-more-reproducible.patch" Content-Disposition: attachment; filename="0001-Make-.pdmp-file-more-reproducible.patch" Content-Transfer-Encoding: quoted-printable >From 9ac586928bbef16b572bcb34bfcbcb5515c2335a Mon Sep 17 00:00:00 2001 From: Paul Eggert 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=3DUTF-8 Content-Transfer-Encoding: 8bit Problem reported by Ulrich M=C3=BCller and diagnosed by Andreas Schwab . * 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 =20 - argc =3D maybe_disable_address_randomization ( - will_dump_with_unexec_p (), argc, argv); + argc =3D maybe_disable_address_randomization (argc, argv); =20 #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 !=3D INV= ALID_HANDLE_VALUE) =20 /* 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[] =3D "--__aslr-disabled"; =20 if (argc < 2 || strcmp (argv[1], aslr_disabled_option) !=3D 0) { - bool disable_aslr =3D 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 =3D will_dump_p (); # ifdef __PPC64__ disable_aslr =3D true; # endif --=20 2.23.0 --------------456187E57C14723A555D0D5A--