From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 06 11:20:12 2018 Received: (at submit) by debbugs.gnu.org; 6 Aug 2018 15:20:12 +0000 Received: from localhost ([127.0.0.1]:42834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmhIq-0008PA-0V for submit@debbugs.gnu.org; Mon, 06 Aug 2018 11:20:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44103) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmc3N-0006dG-TA for submit@debbugs.gnu.org; Mon, 06 Aug 2018 05:43:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmc3H-0002rY-OH for submit@debbugs.gnu.org; Mon, 06 Aug 2018 05:43:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmc3H-0002rL-JF for submit@debbugs.gnu.org; Mon, 06 Aug 2018 05:43:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmc3G-0005Lr-Cn for bug-gzip@gnu.org; Mon, 06 Aug 2018 05:43:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmc3B-0002mb-FZ for bug-gzip@gnu.org; Mon, 06 Aug 2018 05:43:46 -0400 Received: from mail-out-4.itc.rwth-aachen.de ([134.130.5.49]:64860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmc3B-0002jz-2M for bug-gzip@gnu.org; Mon, 06 Aug 2018 05:43:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DYBADIF2hb/6EagoZbHQEBBQELAYNOg?= =?us-ascii?q?hSYQZluCyyHZiE4FAECAQECAQECbSiHdYMzAYF/BJ0TkBKEX4VMEw8JAYh/gVg?= =?us-ascii?q?/gRInH4gXgmWCJAKIA4UthG6IFQcCfXuBcoFZkjkYhVGQBIIzAgICAgkCFIFYI?= =?us-ascii?q?YFSTSR5AYI/PZAXgWIIGY1kAYEaAQE?= X-IPAS-Result: =?us-ascii?q?A2DYBADIF2hb/6EagoZbHQEBBQELAYNOghSYQZluCyyHZiE?= =?us-ascii?q?4FAECAQECAQECbSiHdYMzAYF/BJ0TkBKEX4VMEw8JAYh/gVg/gRInH4gXgmWCJ?= =?us-ascii?q?AKIA4UthG6IFQcCfXuBcoFZkjkYhVGQBIIzAgICAgkCFIFYIYFSTSR5AYI/PZA?= =?us-ascii?q?XgWIIGY1kAYEaAQE?= X-IronPort-AV: E=Sophos;i="5.51,452,1526335200"; d="md'?scan'208";a="16105703" Received: from rwthex-s3-b.rwth-ad.de ([134.130.26.161]) by mail-in-4.itc.rwth-aachen.de with ESMTP; 06 Aug 2018 11:43:39 +0200 Received: from unknown.fritz.box (80.144.95.75) by rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 6 Aug 2018 11:43:35 +0200 From: Johannes Przybilla Content-Type: multipart/mixed; boundary="Apple-Mail=_450ABC84-3B2F-40A5-927B-CA48CB845A4E" MIME-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Bug Gzip v1.9 Message-ID: Date: Mon, 6 Aug 2018 11:43:30 +0200 To: X-Mailer: Apple Mail (2.3273) X-Originating-IP: [80.144.95.75] X-ClientProxiedBy: rwthex-s3-a.rwth-ad.de (2002:8682:1aa0::8682:1aa0) To rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 06 Aug 2018 11:20:09 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) --Apple-Mail=_450ABC84-3B2F-40A5-927B-CA48CB845A4E Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii" Hello. We believe to have found a bug in gzip's signal handler. Attached will you find our bug report. Excited to hear from you! Greetings from Germany, Johannes Przybilla --Apple-Mail=_450ABC84-3B2F-40A5-927B-CA48CB845A4E Content-Disposition: attachment; filename="gzip-report.md" Content-Type: text/markdown; x-unix-mode=0644; name="gzip-report.md" Content-Transfer-Encoding: 7bit Gzip v1.9 In `gzip.c`, the signal handler `abort_gzip_signal` calls the function `remove_output_file` in a signal context. This function uses the non-`volatile` file-level variable `char ofname[MAX_PATH_LEN]` and passes it to `int xunlink(char *filename)`, which in turn calls `int unlink(const char *path)` with it. The problem with this chain of events is that it is not technically guaranteed that the value of a non-`volatile` variable, such as `ofname`, is committed to memory from the main thread of execution. The probably easiest way to deal with this problem is to declare `ofname` as `volatile`, as in `volatile char ofname[MAX_PATH_LEN]`. Note that this will require a whole slew of follow-up changes (e.g., instead of calling `strcpy(ofname, "stdout")`, a string copying function that is guaranteed to utilize volatile memory accesses would be needed). This behavior was detected using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. This research is supported by the European Research Council (ERC) under the EU's Horizon 2020 Research and Innovation Programme grant agreement n. 647295 (SYMBIOSYS). --Apple-Mail=_450ABC84-3B2F-40A5-927B-CA48CB845A4E-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 06 17:47:56 2018 Received: (at 32375) by debbugs.gnu.org; 6 Aug 2018 21:47:56 +0000 Received: from localhost ([127.0.0.1]:42963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmnM2-0003KZ-Vp for submit@debbugs.gnu.org; Mon, 06 Aug 2018 17:47:56 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmnM0-0003KG-8E for 32375@debbugs.gnu.org; Mon, 06 Aug 2018 17:47:53 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 48CEB160654; Mon, 6 Aug 2018 14:47:46 -0700 (PDT) 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 SKS6QCpRNTpl; Mon, 6 Aug 2018 14:47:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F09AB160874; Mon, 6 Aug 2018 14:47:44 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 BO5X4OYAcK4e; Mon, 6 Aug 2018 14:47:44 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 8D205160654; Mon, 6 Aug 2018 14:47:44 -0700 (PDT) Subject: Re: bug#32375: Bug Gzip v1.9 To: Johannes Przybilla , 32375@debbugs.gnu.org References: From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu;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F1Fy/tvkhffSo8u+dwG0EgJh+te38gTcISVr0G IPplLz6YhjrbHrPRF1CN5UuL9DBGjxuN35RLNVEfta6RUFlR6NctTjvrABEBAAHCwWUEGAEC AA8FAkyAcmQCGwwFCRLMAwAACgkQ7ZfpDmKqfjSrHA/+KzAKvTxRhA9MWNLxIyJ7S5uJ16gs T3oCjZrBKGEhKMOGX4O0GA6VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: Date: Mon, 6 Aug 2018 14:47:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------DCB807E73C623AA15049CAD2" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 Cc: Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------DCB807E73C623AA15049CAD2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Thanks for reporting the bug. Although I doubt whether it can occur on an= y=20 practical platform, we should fix it even if it's just theoretical. I ins= talled=20 into gzip master on savannah the attached patch, which I hope fixes the p= roblem;=20 please give it a try. The SYMBIOSYS tool did not discover a related theoretical bug with the=20 'caught_signals' variable, which also is used inside a signal handler des= pite=20 not being volatile, so you might want to look into that. The attached pat= ch=20 should fix this related bug too. I am CC'ing this to Bdale Garbee, since much of this patch brings in a Gn= ulib=20 replacement for sigaction that I expect nowadays is used only on mingw, a= nd=20 Bdale is my mingw guru (see Bug#32305). --------------DCB807E73C623AA15049CAD2 Content-Type: text/x-patch; name="0001-Fix-some-theoretical-races-in-signal-handling.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-some-theoretical-races-in-signal-handling.patch" =46rom f9c96538a4b3458893f48ea73a1b45fd393805fd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 6 Aug 2018 14:44:41 -0700 Subject: [PATCH] Fix some theoretical races in signal handling Problem reported by Johannes Przybilla (Bug#32375). * NEWS: Mention this. * bootstrap.conf (gnulib_modules): Add sigaction. * gzip.c (SA_NOCLDSTOP, sigprocmask, sigset_t) (siginterrupt) [!SA_NOCLDSTOP]: Remove; Gnulib not supplies these. (remove_ofname): New var. (volatile_strcpy): New function. (create_outfile): Use it. (install_signal_handlers, abort_gzip_signal): Assume sigaction. (remove_output_file): New arg SIGNALS_ALREADY_BLOCKED. All uses changed. Avoid unnecessary (and racy) call to sigprocmask if this new arg is set. (abort_gzip_signal): Assume C89 or better for signal handler type. * gzip.h (RETSIGTYPE): Remove. * lib/.gitignore, m4/.gitignore: Add files brought in by Gnulib sigaction module. Sort. --- NEWS | 6 +++++ bootstrap.conf | 1 + gzip.c | 63 ++++++++++++++++++++------------------------------ gzip.h | 4 ---- lib/.gitignore | 9 +++++++- m4/.gitignore | 10 +++++--- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/NEWS b/NEWS index 49c2e9b..c3113ed 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,12 @@ GNU gzip NEWS -*- o= utline -*- regular files will use null timestamps after the year 2106, due to a limitation in the gzip format.) =20 +** Bug fixes + + A few theoretical race conditions in signal handers have been fixed. + These bugs most likely do not happen on practical platforms. + [bugs present since the beginning] + =20 * Noteworthy changes in release 1.9 (2018-01-07) [stable] =20 diff --git a/bootstrap.conf b/bootstrap.conf index 8c4b075..76690fc 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -52,6 +52,7 @@ printf-posix readme-release realloc-gnu savedir +sigaction stat-time stdnoreturn sys_stat diff --git a/gzip.c b/gzip.c index b26dd14..1c9bc6c 100644 --- a/gzip.c +++ b/gzip.c @@ -119,17 +119,6 @@ static char const *const license_msg[] =3D { # define OFF_T_MAX TYPE_MAXIMUM (off_t) #endif =20 -/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is - present. */ -#ifndef SA_NOCLDSTOP -# define SA_NOCLDSTOP 0 -# define sigprocmask(how, set, oset) /* empty */ -# define sigset_t int -# if ! HAVE_SIGINTERRUPT -# define siginterrupt(sig, flag) /* empty */ -# endif -#endif - #ifndef HAVE_WORKING_O_NOFOLLOW # define HAVE_WORKING_O_NOFOLLOW 0 #endif @@ -211,8 +200,10 @@ static sigset_t caught_signals; suppresses a "Broken Pipe" message with some shells. */ static int volatile exiting_signal; =20 -/* If nonnegative, close this file descriptor and unlink ofname on error= =2E */ +/* If nonnegative, close this file descriptor and unlink remove_ofname + on error. */ static int volatile remove_ofname_fd =3D -1; +static char volatile remove_ofname[MAX_PATH_LEN]; =20 static bool stdin_was_read; =20 @@ -323,8 +314,8 @@ local void do_list (int ifd, int method); local int check_ofname (void); local void copy_stat (struct stat *ifstat); local void install_signal_handlers (void); -local void remove_output_file (void); -local RETSIGTYPE abort_gzip_signal (int); +static void remove_output_file (bool); +static void abort_gzip_signal (int); local noreturn void do_exit (int exitcode); static void finish_out (void); int main (int argc, char **argv); @@ -1062,7 +1053,7 @@ local void treat_file(iname) =20 if (method =3D=3D -1) { if (!to_stdout) - remove_output_file (); + remove_output_file (false); return; } =20 @@ -1082,6 +1073,13 @@ local void treat_file(iname) } } =20 +static void +volatile_strcpy (char volatile *dst, char const *src) +{ + while ((*dst++ =3D *src++)) + continue; +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * Create the output file. Return OK or ERROR. * Try several times if necessary to avoid truncating the z_suffix. For @@ -1115,6 +1113,8 @@ local int create_outfile() int open_errno; sigset_t oldset; =20 + volatile_strcpy (remove_ofname, ofname); + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); remove_ofname_fd =3D ofd =3D openat (atfd, base, flags, S_IRUSR | = S_IWUSR); open_errno =3D errno; @@ -2061,8 +2061,6 @@ install_signal_handlers () { int nsigs =3D sizeof handled_sig / sizeof handled_sig[0]; int i; - -#if SA_NOCLDSTOP struct sigaction act; =20 sigemptyset (&caught_signals); @@ -2084,16 +2082,6 @@ install_signal_handlers () foreground =3D 1; sigaction (handled_sig[i], &act, NULL); } -#else - for (i =3D 0; i < nsigs; i++) - if (signal (handled_sig[i], SIG_IGN) !=3D SIG_IGN) - { - if (i =3D=3D 0) - foreground =3D 1; - signal (handled_sig[i], abort_gzip_signal); - siginterrupt (handled_sig[i], 1); - } -#endif } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -2133,12 +2121,13 @@ finish_out (void) * Close and unlink the output file. */ static void -remove_output_file () +remove_output_file (bool signals_already_blocked) { int fd; sigset_t oldset; =20 - sigprocmask (SIG_BLOCK, &caught_signals, &oldset); + if (!signals_already_blocked) + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); fd =3D remove_ofname_fd; if (0 <=3D fd) { @@ -2146,29 +2135,27 @@ remove_output_file () close (fd); xunlink (ofname); } - sigprocmask (SIG_SETMASK, &oldset, NULL); + if (!signals_already_blocked) + sigprocmask (SIG_SETMASK, &oldset, NULL); } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * Error handler. */ void -abort_gzip () +abort_gzip (void) { - remove_output_file (); + remove_output_file (false); do_exit(ERROR); } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * Signal handler. */ -static RETSIGTYPE -abort_gzip_signal (sig) - int sig; +static void +abort_gzip_signal (int sig) { - if (! SA_NOCLDSTOP) - signal (sig, SIG_IGN); - remove_output_file (); + remove_output_file (true); if (sig =3D=3D exiting_signal) _exit (WARNING); signal (sig, SIG_DFL); diff --git a/gzip.h b/gzip.h index 2499337..329c9a5 100644 --- a/gzip.h +++ b/gzip.h @@ -41,10 +41,6 @@ #include #define memzero(s, n) memset ((voidp)(s), 0, (n)) =20 -#ifndef RETSIGTYPE -# define RETSIGTYPE void -#endif - #define local static =20 typedef unsigned char uch; diff --git a/lib/.gitignore b/lib/.gitignore index cd11296..6a21391 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -146,6 +146,7 @@ /printf-parse.c /printf-parse.h /printf.c +/raise.c /readdir.c /realloc.c /rmdir.c @@ -153,9 +154,15 @@ /save-cwd.h /savedir.c /savedir.h +/sig-handler.c +/sig-handler.h +/sigaction.c +/signal.h +/signal.in.h /signbitd.c /signbitf.c /signbitl.c +/sigprocmask.c /size_max.h /stamp-h1 /stat-time.c @@ -175,6 +182,7 @@ /stdio.in.h /stdlib.h /stdlib.in.h +/stdnoreturn.in.h /stpcpy.c /strdup.c /strerror-override.c @@ -218,4 +226,3 @@ /xsize.h /yesno.c /yesno.h -/stdnoreturn.in.h diff --git a/m4/.gitignore b/m4/.gitignore index 5ce3776..7f5c059 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -58,6 +58,7 @@ /gnulib-common.m4 /gnulib-comp.m4 /gnulib-tool.m4 +/host-cpu-c-abi.m4 /include_next.m4 /intmax_t.m4 /inttypes_h.m4 @@ -102,11 +103,15 @@ /printf-posix-rpl.m4 /printf.m4 /pthread_rwlock_rdlock.m4 +/raise.m4 /readdir.m4 /realloc.m4 /rmdir.m4 /save-cwd.m4 /savedir.m4 +/sigaction.m4 +/signal_h.m4 +/signalblocking.m4 /signbit.m4 /size_max.m4 /ssize_t.m4 @@ -118,6 +123,7 @@ /stdint_h.m4 /stdio_h.m4 /stdlib_h.m4 +/stdnoreturn.m4 /stpcpy.m4 /strdup.m4 /strerror.m4 @@ -147,7 +153,5 @@ /wint_t.m4 /xalloc.m4 /xsize.m4 -/yesno.m4 -/host-cpu-c-abi.m4 /year2038.m4 -/stdnoreturn.m4 +/yesno.m4 --=20 2.17.1 --------------DCB807E73C623AA15049CAD2-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 07 18:52:19 2018 Received: (at 32375) by debbugs.gnu.org; 7 Aug 2018 22:52:19 +0000 Received: from localhost ([127.0.0.1]:44004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnApv-0006EX-JJ for submit@debbugs.gnu.org; Tue, 07 Aug 2018 18:52:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnApt-0006EI-M0 for 32375@debbugs.gnu.org; Tue, 07 Aug 2018 18:52:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnApl-0005al-Dl for 32375@debbugs.gnu.org; Tue, 07 Aug 2018 18:52:12 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnApl-0005ah-8m; Tue, 07 Aug 2018 18:52:09 -0400 Received: from 166.red-217-124-67.dialup.dynamic.ccgg.telefonica.net ([217.124.67.166]:34525) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1fnApg-0005t4-Qu; Tue, 07 Aug 2018 18:52:09 -0400 Message-ID: <5B6A2241.6080507@gnu.org> Date: Wed, 08 Aug 2018 00:50:41 +0200 From: Antonio Diaz Diaz User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 MIME-Version: 1.0 To: 32375@debbugs.gnu.org Subject: Re: bug#32375: Bug Gzip v1.9 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32375 Cc: Bdale Garbee , Johannes Przybilla X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Paul Eggert wrote: > Thanks for reporting the bug. Although I doubt whether it can occur on > any practical platform, we should fix it even if it's just theoretical. I have applied to lzip a change similar to yours, but I'm not sure it fixes the theoretical problem. > +static char volatile remove_ofname[MAX_PATH_LEN]; I see two problems with this fix. The first is that it limits filename size. It seems that on GNU/Hurd systems there is no limit to the size of a file name, so this would place an artificial limit to the use of lzip on such systems. The second is that posix states the following: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03 ------------------------------------------------------------------------ If the process is multi-threaded, or if the process is single-threaded and a signal handler is executed other than as the result of: * The process calling abort(), raise(), kill(), pthread_kill(), or sigqueue() to generate a signal that is not blocked * A pending signal being unblocked and being delivered before the call that unblocked it returns the behavior is undefined if the signal handler refers to any object other than errno with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or if the signal handler calls any function defined in this standard other than one of the functions listed in the following table. ------------------------------------------------------------------------ The last paragraph seems to imply that a signal handler can't read any static object, only write to 'volatile sig_atomic_t'. This is how I implemented the Ctrl-C handler in ddrescue, but in the case of gzip and lzip, polling a sig_atomic_t variable may be inefficient or cause a noticeable delay. I find posix too restrictive in this respect. Any thoughts? Antonio. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 08 00:56:29 2018 Received: (at 32375) by debbugs.gnu.org; 8 Aug 2018 04:56:29 +0000 Received: from localhost ([127.0.0.1]:44105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnGWK-0002Se-PE for submit@debbugs.gnu.org; Wed, 08 Aug 2018 00:56:28 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:54246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnGWJ-0002SP-Gc for 32375@debbugs.gnu.org; Wed, 08 Aug 2018 00:56:28 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F1B18160657; Tue, 7 Aug 2018 21:56:20 -0700 (PDT) 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 bi_lM6hNw3UF; Tue, 7 Aug 2018 21:56:20 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4A6741606D7; Tue, 7 Aug 2018 21:56:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 QjRViNvoaC4f; Tue, 7 Aug 2018 21:56:20 -0700 (PDT) Received: from [192.168.1.29] (unknown [47.139.41.115]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B51A3160657; Tue, 7 Aug 2018 21:56:19 -0700 (PDT) Subject: Re: bug#32375: Bug Gzip v1.9 To: Antonio Diaz Diaz , 32375@debbugs.gnu.org References: <5B6A2241.6080507@gnu.org> From: Paul Eggert Message-ID: <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> Date: Tue, 7 Aug 2018 21:56:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <5B6A2241.6080507@gnu.org> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 Cc: Bdale Garbee , Johannes Przybilla X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 08/07/2018 03:50 PM, Antonio Diaz Diaz wrote: > I find posix too restrictive in this respect. Yes, me too. The file name length limit has been in gzip since forever, and is a separate issue (e.g. it happens regardless of signals). So if it is to be fixed it should be a separate bug number. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 08 04:47:40 2018 Received: (at 32375) by debbugs.gnu.org; 8 Aug 2018 08:47:40 +0000 Received: from localhost ([127.0.0.1]:44177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnK83-00005V-E4 for submit@debbugs.gnu.org; Wed, 08 Aug 2018 04:47:39 -0400 Received: from mail-out-4.itc.rwth-aachen.de ([134.130.5.49]:30343) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnJ8S-0006pu-9e for 32375@debbugs.gnu.org; Wed, 08 Aug 2018 03:44:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AYAgCPnmpb/6EagoZcDgwBAQEBAQIBA?= =?us-ascii?q?QEBCAEBAQGDToIKCphEgg2XaQsshEACgwUhOBQBAgEBAgEBAm0ohTcBAQEDATo?= =?us-ascii?q?/BQsLGB4QVwYOBYMggXkIBKwehGaFcwkBiQqBWD+BOR+CTIRYJoMygiQCjHeNS?= =?us-ascii?q?gcCf3uPHYZvGIVViCOHdII0AgICAgkCFIFYIYFSTSR5AYI+Po9bPG11CBmKW4E?= =?us-ascii?q?tAYEaAQE?= X-IPAS-Result: =?us-ascii?q?A2AYAgCPnmpb/6EagoZcDgwBAQEBAQIBAQEBCAEBAQGDToI?= =?us-ascii?q?KCphEgg2XaQsshEACgwUhOBQBAgEBAgEBAm0ohTcBAQEDATo/BQsLGB4QVwYOB?= =?us-ascii?q?YMggXkIBKwehGaFcwkBiQqBWD+BOR+CTIRYJoMygiQCjHeNSgcCf3uPHYZvGIV?= =?us-ascii?q?ViCOHdII0AgICAgkCFIFYIYFSTSR5AYI+Po9bPG11CBmKW4EtAYEaAQE?= X-IronPort-AV: E=Sophos;i="5.51,456,1526335200"; d="scan'208";a="16253328" Received: from rwthex-s3-b.rwth-ad.de ([134.130.26.161]) by mail-in-4.itc.rwth-aachen.de with ESMTP; 08 Aug 2018 09:43:59 +0200 Received: from unknown.fritz.box (80.141.187.223) by rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 8 Aug 2018 09:43:56 +0200 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: bug#32375: Bug Gzip v1.9 From: Johannes Przybilla In-Reply-To: <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> Date: Wed, 8 Aug 2018 09:43:47 +0200 Content-Transfer-Encoding: quoted-printable Message-ID: <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> References: <5B6A2241.6080507@gnu.org> <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> To: Paul Eggert X-Mailer: Apple Mail (2.3273) X-Originating-IP: [80.141.187.223] X-ClientProxiedBy: rwthex-w1-a.rwth-ad.de (2002:8682:1a9c::8682:1a9c) To rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 X-Mailman-Approved-At: Wed, 08 Aug 2018 04:47:38 -0400 Cc: 32375@debbugs.gnu.org, Antonio Diaz Diaz , Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I agree that the POSIX standard is quite restrictive in this respect. However I believe that is for a good reason. Performing non-atomic memory operations on static objects in a signal = handler can cause problems with reentrancy. This can lead to undefined behaviour for example in the case of nested = signal handler calls that update the same static object. > Am 08.08.2018 um 06:56 schrieb Paul Eggert : >=20 > On 08/07/2018 03:50 PM, Antonio Diaz Diaz wrote: >> I find posix too restrictive in this respect.=20 >=20 > Yes, me too. >=20 > The file name length limit has been in gzip since forever, and is a > separate issue (e.g. it happens regardless of signals). So if it is to > be fixed it should be a separate bug number. >=20 From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 08 05:34:16 2018 Received: (at 32375) by debbugs.gnu.org; 8 Aug 2018 09:34:16 +0000 Received: from localhost ([127.0.0.1]:44190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnKrA-0001H6-5v for submit@debbugs.gnu.org; Wed, 08 Aug 2018 05:34:16 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnKr8-0001Gp-PA for 32375@debbugs.gnu.org; Wed, 08 Aug 2018 05:34:15 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5F14C160657; Wed, 8 Aug 2018 02:34:09 -0700 (PDT) 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 G83SJh5j4m6B; Wed, 8 Aug 2018 02:34:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AC8711606D7; Wed, 8 Aug 2018 02:34:08 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 2d0W-FhSFscE; Wed, 8 Aug 2018 02:34:08 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4E44D160657; Wed, 8 Aug 2018 02:34:08 -0700 (PDT) Subject: Re: bug#32375: Bug Gzip v1.9 To: Johannes Przybilla References: <5B6A2241.6080507@gnu.org> <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1Dl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ieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: <24df754d-cc30-d4e4-8afd-17430d55cb17@cs.ucla.edu> Date: Wed, 8 Aug 2018 02:34:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 Cc: 32375@debbugs.gnu.org, Antonio Diaz Diaz , Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Johannes Przybilla wrote: > This can lead to undefined behaviour for example in the case of nested signal handler calls These can't happen in gzip, so we should be OK here. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 08 07:13:44 2018 Received: (at 32375) by debbugs.gnu.org; 8 Aug 2018 11:13:44 +0000 Received: from localhost ([127.0.0.1]:44236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnMPQ-0003vH-AS for submit@debbugs.gnu.org; Wed, 08 Aug 2018 07:13:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fnMPO-0003v4-9X for 32375@debbugs.gnu.org; Wed, 08 Aug 2018 07:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnMPI-00019l-Bb for 32375@debbugs.gnu.org; Wed, 08 Aug 2018 07:13:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnMPC-00011r-OV; Wed, 08 Aug 2018 07:13:30 -0400 Received: from 151.red-217-124-67.dialup.dynamic.ccgg.telefonica.net ([217.124.67.151]:44534) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1fnMPB-0001FE-OF; Wed, 08 Aug 2018 07:13:30 -0400 Message-ID: <5B6AD004.9000602@gnu.org> Date: Wed, 08 Aug 2018 13:12:04 +0200 From: Antonio Diaz Diaz User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 MIME-Version: 1.0 To: Johannes Przybilla Subject: Re: bug#32375: Bug Gzip v1.9 References: <5B6A2241.6080507@gnu.org> <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> In-Reply-To: <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32375 Cc: 32375@debbugs.gnu.org, Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Johannes Przybilla wrote: > I agree that the POSIX standard is quite restrictive in this > respect. However I believe that is for a good reason. Performing > non-atomic memory operations on static objects in a signal handler > can cause problems with reentrancy. This can lead to undefined > behaviour for example in the case of nested signal handler calls that > update the same static object. This is not at all the case in gzip and gzip-like compressors. In them the handler is executed just once to perform some cleanup operations (mainly remove the partial output file), an then exit. The handler does not perform any non-atomic memory operations on static objects, and control never returns to the main thread. IMO posix should allow to this kind of cleanup handlers read access to any static object. In fact, as Paul pointed out, any practical platform probably allows such read access because many of the functions posix allows to be called from a handler require a filename, which in the case of a cleanup handler is most probably a static object. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 19 06:34:39 2018 Received: (at 32375) by debbugs.gnu.org; 19 Aug 2018 10:34:39 +0000 Received: from localhost ([127.0.0.1]:54396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frL2c-0008Vv-PC for submit@debbugs.gnu.org; Sun, 19 Aug 2018 06:34:38 -0400 Received: from mail-out-4.itc.rwth-aachen.de ([134.130.5.49]:21697) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frL2a-0008Vl-26 for 32375@debbugs.gnu.org; Sun, 19 Aug 2018 06:34:36 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DbBwDXRnlb/6EagoZaDg0BAQEBAwEBA?= =?us-ascii?q?QkBAQGDT4IKCoNllCSBaCWDPY01hx8LLIRAAoNGITgUAQIBAQIBAQJtKIU3AQE?= =?us-ascii?q?BAwEjVgULCxgCAiYCAkcQBg4FgyKBeggEpFqBLoRohXAJAYEBiA2BWD+BOQwTg?= =?us-ascii?q?kyEfoMBMYImApJAiDwHAoEDfQSNcYEwhwsYhWWQTII1AgICAgkCFIFYIYFSTSR?= =?us-ascii?q?5AYI+Po9bPG11CBmMIQGBGgEB?= X-IPAS-Result: =?us-ascii?q?A2DbBwDXRnlb/6EagoZaDg0BAQEBAwEBAQkBAQGDT4IKCoN?= =?us-ascii?q?llCSBaCWDPY01hx8LLIRAAoNGITgUAQIBAQIBAQJtKIU3AQEBAwEjVgULCxgCA?= =?us-ascii?q?iYCAkcQBg4FgyKBeggEpFqBLoRohXAJAYEBiA2BWD+BOQwTgkyEfoMBMYImApJ?= =?us-ascii?q?AiDwHAoEDfQSNcYEwhwsYhWWQTII1AgICAgkCFIFYIYFSTSR5AYI+Po9bPG11C?= =?us-ascii?q?BmMIQGBGgEB?= X-IronPort-AV: E=Sophos;i="5.53,260,1531778400"; d="scan'208";a="17015734" Received: from rwthex-s3-b.rwth-ad.de ([134.130.26.161]) by mail-in-4.itc.rwth-aachen.de with ESMTP; 19 Aug 2018 12:34:35 +0200 Received: from unknown.fritz.box (80.144.86.113) by rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Sun, 19 Aug 2018 12:34:32 +0200 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: bug#32375: Bug Gzip v1.9 From: Johannes Przybilla In-Reply-To: <24df754d-cc30-d4e4-8afd-17430d55cb17@cs.ucla.edu> Date: Sun, 19 Aug 2018 12:34:22 +0200 Content-Transfer-Encoding: quoted-printable Message-ID: <2C120265-5730-4D36-B3AF-02726C64C184@rwth-aachen.de> References: <5B6A2241.6080507@gnu.org> <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> <24df754d-cc30-d4e4-8afd-17430d55cb17@cs.ucla.edu> To: Paul Eggert X-Mailer: Apple Mail (2.3273) X-Originating-IP: [80.144.86.113] X-ClientProxiedBy: rwthex-s1-a.rwth-ad.de (2002:8682:1a98::8682:1a98) To rwthex-s3-b.rwth-ad.de (2002:8682:1aa1::8682:1aa1) X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 Cc: 32375@debbugs.gnu.org, Antonio Diaz Diaz , Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello Paul. I only recently got around to check the fix you committed. It seems to me that after 'volatile_strcpy (remove_ofname, ofname);=E2=80=98= the 'remove_ofname=E2=80=98 variable is not used anymore. The 'xunlink' function in 'remove_output_file' is still called on = 'ofname' instead of 'remove_ofname=E2=80=98. Therefore the non-volatile access still occurs in the signal handler. Could you look into that? Best regards, Johannes > Am 08.08.2018 um 11:34 schrieb Paul Eggert : >=20 > Johannes Przybilla wrote: >> This can lead to undefined behaviour for example in the case of = nested signal handler calls >=20 > These can't happen in gzip, so we should be OK here. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 19 07:18:59 2018 Received: (at 32375) by debbugs.gnu.org; 19 Aug 2018 11:18:59 +0000 Received: from localhost ([127.0.0.1]:54426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frLjW-0001xW-Sp for submit@debbugs.gnu.org; Sun, 19 Aug 2018 07:18:59 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frLjV-0001xK-Qf for 32375@debbugs.gnu.org; Sun, 19 Aug 2018 07:18:58 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 593AC16081D; Sun, 19 Aug 2018 04:18:52 -0700 (PDT) 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 DKoHpSa0Gps6; Sun, 19 Aug 2018 04:18:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 982F216087B; Sun, 19 Aug 2018 04:18:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 Q1mloLGGBlzX; Sun, 19 Aug 2018 04:18:51 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2152E16081D; Sun, 19 Aug 2018 04:18:51 -0700 (PDT) Subject: Re: bug#32375: Bug Gzip v1.9 To: Johannes Przybilla References: <5B6A2241.6080507@gnu.org> <30efff6f-59d7-63a6-83e8-606b1c878141@cs.ucla.edu> <6D8BDF4D-E0EA-4C3B-BAEA-CD5D865E6C25@rwth-aachen.de> <24df754d-cc30-d4e4-8afd-17430d55cb17@cs.ucla.edu> <2C120265-5730-4D36-B3AF-02726C64C184@rwth-aachen.de> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sun, 19 Aug 2018 04:18:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <2C120265-5730-4D36-B3AF-02726C64C184@rwth-aachen.de> Content-Type: multipart/mixed; boundary="------------FDAD9BB787337717768DC72B" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32375 Cc: 32375@debbugs.gnu.org, Antonio Diaz Diaz , Bdale Garbee X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------FDAD9BB787337717768DC72B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Johannes Przybilla wrote: > Therefore the non-volatile access still occurs in the signal handler. Good catch, thanks. I installed the attached further patch; please give it a try. Signal handlers are such a pain. --------------FDAD9BB787337717768DC72B Content-Type: text/x-patch; name="gzip.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gzip.diff" diff --git a/gzip.c b/gzip.c index 1c9bc6c..e6a7761 100644 --- a/gzip.c +++ b/gzip.c @@ -1074,7 +1074,7 @@ local void treat_file(iname) } static void -volatile_strcpy (char volatile *dst, char const *src) +volatile_strcpy (char volatile *dst, char const volatile *src) { while ((*dst++ = *src++)) continue; @@ -2131,9 +2131,11 @@ remove_output_file (bool signals_already_blocked) fd = remove_ofname_fd; if (0 <= fd) { + char fname[MAX_PATH_LEN]; remove_ofname_fd = -1; close (fd); - xunlink (ofname); + volatile_strcpy (fname, remove_ofname); + xunlink (fname); } if (!signals_already_blocked) sigprocmask (SIG_SETMASK, &oldset, NULL); --------------FDAD9BB787337717768DC72B-- From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 20:23:20 2022 Received: (at control) by debbugs.gnu.org; 30 Mar 2022 00:23:20 +0000 Received: from localhost ([127.0.0.1]:33935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZM7M-0001fI-Ak for submit@debbugs.gnu.org; Tue, 29 Mar 2022 20:23:20 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZM7K-0001ew-41 for control@debbugs.gnu.org; Tue, 29 Mar 2022 20:23:18 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B4CCE16005E for ; Tue, 29 Mar 2022 17:23:12 -0700 (PDT) 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 NNpnoMgDrMkm for ; Tue, 29 Mar 2022 17:23:12 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1EFB716006C for ; Tue, 29 Mar 2022 17:23:12 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 1rI32iHU2-Wl for ; Tue, 29 Mar 2022 17:23:12 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 05B9916005E for ; Tue, 29 Mar 2022 17:23:12 -0700 (PDT) Message-ID: Date: Tue, 29 Mar 2022 17:23:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: GNU bug control From: Paul Eggert Subject: gzip bug maintenance Organization: UCLA Computer Science Department Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 35145 wishlist severity 50097 wishlist tags 33302 notabug close 33302 tags 33070 + notabug close 33070 tags 32865 notabug close 32865 tags 32824 notabug close 32824 tags 32815 notabug close 32815 tags 32721 notabug close 32721 close 32684 tags 32415 moreinfo close 32375 From unknown Sun Jun 15 09:02:51 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 27 Apr 2022 11:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator