From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 824A53858D38; Mon, 20 Nov 2023 22:28:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 824A53858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700519306; bh=A6YlHNACTIH9pqOXFOy4UMCjr7qhiTXhm0ogd2jdQbY=; h=From:To:Subject:Date:From; b=jlCaBYj/1KjKyHxdwXfvGGbUq0jqlNHu96l32v2YS1cW7+NsN9t3JVOnLSF6nywp5 aMxSuneS050pDQMbSYHEvRfdOMvt55pgxjINWxBDCaY8w4iX7Y39fTcKLtBQktPRaH GMJGpo6KF8sOG9A5IrHC76hBDe5qKsuqDFiy3VF8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] hurd: Prevent the final file_exec_paths call from signals X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/master X-Git-Oldrev: 3cbaacdfd2c11cb726011ef6464dce00c186a2bf X-Git-Newrev: 49b308a26e2a9e02ef396f67f59c462ad4171ea4 Message-Id: <20231120222826.824A53858D38@sourceware.org> Date: Mon, 20 Nov 2023 22:28:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=49b308a26e2a9e02ef396f67f59c462ad4171ea4 commit 49b308a26e2a9e02ef396f67f59c462ad4171ea4 Author: Samuel Thibault Date: Mon Nov 20 19:19:50 2023 +0100 hurd: Prevent the final file_exec_paths call from signals Otherwise if the exec server started thrashing the old task, we won't be able to restart the exec. This notably fixes building ghc. Diff: --- hurd/hurdexec.c | 12 ++++++++++++ sysdeps/mach/hurd/spawni.c | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c index e358d846c8..317d7ea0ad 100644 --- a/hurd/hurdexec.c +++ b/hurd/hurdexec.c @@ -362,6 +362,7 @@ retry: if (!err) { int flags; + sigset_t old, new; if (pdp) { @@ -420,6 +421,15 @@ retry: if (__sigismember (&_hurdsig_traced, SIGKILL)) flags |= EXEC_SIGTRAP; #endif + + /* Avoid getting interrupted while exec(), notably not after the exec + server has committed to the exec and started thrashing us. + + TODO Rather add proper interrupt support to the exec server, that + avoids interrupts in that period. */ + __sigfillset (&new); + __sigprocmask (SIG_SETMASK, &new, &old); + err = __file_exec_paths (file, task, flags, path ? path : "", abspath ? abspath : "", @@ -440,6 +450,8 @@ retry: ints, INIT_INT_MAX, please_dealloc, pdp - please_dealloc, portnames, nportnames); + + __sigprocmask (SIG_SETMASK, &old, NULL); } /* Release references to the standard ports. */ diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index 9516001817..58a89b45f3 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -812,6 +812,18 @@ retry: inline error_t exec (file_t file) { + sigset_t old, new; + + /* Avoid getting interrupted while exec(), notably not after the exec + server has committed to the exec and started thrashing the task. + + Various issues otherwise show up when building e.g. ghc. + + TODO Rather add proper interrupt support to the exec server, that + avoids interrupts in that period. */ + __sigfillset(&new); + __sigprocmask (SIG_SETMASK, &new, &old); + error_t err = __file_exec_paths (file, task, __sigismember (&_hurdsig_traced, SIGKILL) ? EXEC_SIGTRAP : 0, @@ -824,7 +836,7 @@ retry: /* Fallback for backwards compatibility. This can just be removed when __file_exec goes away. */ if (err == MIG_BAD_ID) - return __file_exec (file, task, + err = __file_exec (file, task, (__sigismember (&_hurdsig_traced, SIGKILL) ? EXEC_SIGTRAP : 0), args, argslen, env, envlen, @@ -833,6 +845,8 @@ retry: ints, INIT_INT_MAX, NULL, 0, NULL, 0); + __sigprocmask (SIG_SETMASK, &old, NULL); + return err; }