From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 7FEF33858D35; Tue, 21 Nov 2023 06:27:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FEF33858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700548062; bh=2v+UfHTmr0sAQLAPKsznQWXa8ueN7Eehrl8yIxi2EsM=; h=From:To:Subject:Date:From; b=gFpWSN+Cb1UBxyC0E4155FwrowmIOqzkFaMLe6w5r4+NsS3snIjwjO31pwpHXXqPJ l24rkFw+3LJ1dgvM0izule4s1SNy0tOl6QTfebacco90li65MyyfgFBvBKnO81XxWg oqX53BF+lpLhMUO/omKU/Uc2aQOEuu8zVHAJ2VdA= 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: fix restarting reauth_dtable on signal X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/master X-Git-Oldrev: 49b308a26e2a9e02ef396f67f59c462ad4171ea4 X-Git-Newrev: dd858522bf36ae16496ea01ff8b65e16b4e5c22b Message-Id: <20231121062742.7FEF33858D35@sourceware.org> Date: Tue, 21 Nov 2023 06:27:42 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dd858522bf36ae16496ea01ff8b65e16b4e5c22b commit dd858522bf36ae16496ea01ff8b65e16b4e5c22b Author: Samuel Thibault Date: Tue Nov 21 00:55:54 2023 +0100 hurd: fix restarting reauth_dtable on signal While inside the critical section, RPCs would not be restarted, so we have to handle EINTR errors. Diff: --- 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);