From patchwork Tue Nov 21 06:27:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 80424 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F15A93858402 for ; Tue, 21 Nov 2023 06:28:20 +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 193DE3858D35 for ; Tue, 21 Nov 2023 06:28:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 193DE3858D35 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 193DE3858D35 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=1700548089; cv=none; b=ULzSA4G42/2MP6lCocYTY5cDfS4DoZ5zM66+9K5kGDy5pScOuB03gWn1c2+ay+cC0TNrZlmq9PN7omIGssrzyKuxze4sDKQYnck+2+s8Fiwz7zUQzqGkaKaUItm117h+v7jUoEaZqRh6qcqiiiD0afMqBQX9xvlIOQApwcrxQik= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700548089; c=relaxed/simple; bh=lyXBn2SbLy2ifq07e30AWk/8QIm6gzXBJme8OgsJl9s=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hBpyGZ2h5n0R4hZ4v9d1IXQWSL6gkWfhD/PttS4DcY+gzDy+WSfbZmJDTMKYo1YomrtCCNUv6YKDP7omWrUvNRWJ8JUE8WtBuj5xZ9+XrDzcAPp/W/u+fqRtezOVKpGyOvIqWrpwOOcBHitF+T47kPOxDXAeTFlDZ2rQQJ31VlI= 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 01AE92011A; Tue, 21 Nov 2023 07:28:07 +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 r-S4kK97kuDe; Tue, 21 Nov 2023 07:28:06 +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 C220E200EB; Tue, 21 Nov 2023 07:28:06 +0100 (CET) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1r5KEw-00000009KtS-0aWU; Tue, 21 Nov 2023 07:28:06 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited] hurd: fix restarting reauth_dtable on signal Date: Tue, 21 Nov 2023 07:27:57 +0100 Message-ID: <20231121062757.2225257-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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+patchwork=sourceware.org@sourceware.org While inside the critical section, RPCs would not be restarted, so we have to handle EINTR errors. --- hurd/dtable.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/hurd/dtable.c b/hurd/dtable.c index 41f4d7afef..eaf4734a35 100644 --- a/hurd/dtable.c +++ b/hurd/dtable.c @@ -289,6 +289,7 @@ reauth_dtable (void) { int i; +retry: HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_dtable_lock); @@ -296,6 +297,7 @@ reauth_dtable (void) { struct hurd_fd *const d = _hurd_dtable[i]; mach_port_t new, newctty, ref; + error_t err = 0; if (d == NULL) /* Nothing to do for an unused descriptor cell. */ @@ -308,23 +310,23 @@ reauth_dtable (void) /* Reauthenticate the descriptor's port. */ if (d->port.port != MACH_PORT_NULL - && ! __io_reauthenticate (d->port.port, - ref, MACH_MSG_TYPE_MAKE_SEND) - && ! __USEPORT (AUTH, __auth_user_authenticate - (port, - ref, MACH_MSG_TYPE_MAKE_SEND, - &new))) + && ! (err = __io_reauthenticate (d->port.port, + ref, MACH_MSG_TYPE_MAKE_SEND)) + && ! (err = __USEPORT (AUTH, __auth_user_authenticate + (port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &new)))) { /* Replace the port in the descriptor cell with the newly reauthenticated port. */ if (d->ctty.port != MACH_PORT_NULL - && ! __io_reauthenticate (d->ctty.port, - ref, MACH_MSG_TYPE_MAKE_SEND) - && ! __USEPORT (AUTH, __auth_user_authenticate - (port, - ref, MACH_MSG_TYPE_MAKE_SEND, - &newctty))) + && ! (err = __io_reauthenticate (d->ctty.port, + ref, MACH_MSG_TYPE_MAKE_SEND)) + && ! (err = __USEPORT (AUTH, __auth_user_authenticate + (port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &newctty)))) _hurd_port_set (&d->ctty, newctty); _hurd_port_locked_set (&d->port, new); @@ -334,6 +336,15 @@ reauth_dtable (void) __spin_unlock (&d->port.lock); __mach_port_destroy (__mach_task_self (), ref); + + if (err == EINTR) + { + /* Got a signal while inside an RPC of the critical section, + retry again */ + __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_UNLOCK; + goto retry; + } } __mutex_unlock (&_hurd_dtable_lock);