git-dtable_reauth
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Wed, 31 Jan 2024 20:45:37 +0000 (21:45 +0100)
committerAurelien Jarno <aurel32@debian.org>
Wed, 31 Jan 2024 20:45:37 +0000 (21:45 +0100)
commit dd858522bf36ae16496ea01ff8b65e16b4e5c22b
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
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.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-dtable_reauth.diff

hurd/dtable.c

index 5dd0413191db20c6409a4ecb2c19d3f8923c48da..d63f827c3b190f22bb756bdb5a9fce8976e43055 100644 (file)
@@ -257,6 +257,7 @@ reauth_dtable (void)
 {
   int i;
 
+retry:
   HURD_CRITICAL_BEGIN;
   __mutex_lock (&_hurd_dtable_lock);
 
@@ -264,6 +265,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.  */
@@ -276,23 +278,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);
@@ -302,6 +304,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);