From patchwork Mon Nov 20 22:28:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1866322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SZ2Gj1kzxz1ySS for ; Tue, 21 Nov 2023 09:28:45 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AD853858C39 for ; Mon, 20 Nov 2023 22:28:42 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 86BE73858D39 for ; Mon, 20 Nov 2023 22:28:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86BE73858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86BE73858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700519316; cv=none; b=A3mgMyIaacD1KLijjDG0W7gPpLleA6EQ0IXw48ER1puDLJBkgcdzxiB5CtychXSRXHA8U0y4ZFwVtGrZNj5UMyUkEgYrpe7K7m+brmPZsNDxpP+sOKbP033Mrvh1ll/Ca6uH4ynJdZXcrdL6h7xdSx5U2FRSrk7tZSe8pBf/RWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700519316; c=relaxed/simple; bh=wBN011RdOQcVhEOWQVapN3ss+EI97mZCwn3zE+jo+m0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=SAI6RrW9YFaljohCQpJm6gSnaYL/mMUJc7s5564XQKRB7QBzKSZXUlRrH3w426M7AlOJB0aHa3AmvsGkqt+emKbJVcDur0MXOigFS6DfqTTcKgAFURE0fFdcz5Ib2sZoU4/0PuB8p3I+Z3Lt8FnKqTNcrAz24j/5mnJxkDbIlEM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 7288420134; Mon, 20 Nov 2023 23:28:32 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M7PqGXRpN0wI; Mon, 20 Nov 2023 23:28:32 +0100 (CET) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 569822011A; Mon, 20 Nov 2023 23:28:32 +0100 (CET) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1r5Ckq-00000008ArO-01XD; Mon, 20 Nov 2023 23:28:32 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] hurd: Prevent the final file_exec_paths call from signals Date: Mon, 20 Nov 2023 23:28:31 +0100 Message-ID: <20231120222831.1948336-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Otherwise if the exec server started thrashing the old task, we won't be able to restart the exec. This notably fixes building ghc. --- 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; }