git-auth-leak
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sun, 10 Jul 2022 20:29:34 +0000 (21:29 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sun, 10 Jul 2022 20:29:34 +0000 (21:29 +0100)
Committed for 2.35

commit 0e298448aad6fabf455923e72e0d1a3c56e9ab9e
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Jan 2 04:08:11 2022 +0100

    hurd: Fix auth port leak

    If access() was used before exec, _hurd_id.rid_auth would cache an
    "effective" auth port.  We do not want this to leak into the executed
    program.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-auth-leak.diff

hurd/hurdexec.c

index c39da7cf2854f25b20032f9d355c0ecdc103a7d5..6a389ed6c48470c9ed71b8cb7f4352d8dd8ec921 100644 (file)
@@ -229,6 +229,14 @@ retry:
      reflects that our whole ID set differs from what we've set it to.  */
   __mutex_lock (&_hurd_id.lock);
   err = _hurd_check_ids ();
+
+  /* Avoid leaking the rid_auth port reference to the new progam */
+  if (_hurd_id.rid_auth != MACH_PORT_NULL)
+    {
+      __mach_port_deallocate (__mach_task_self (), _hurd_id.rid_auth);
+      _hurd_id.rid_auth = MACH_PORT_NULL;
+    }
+
   if (err == 0 && ((_hurd_id.aux.nuids >= 2 && _hurd_id.gen.nuids >= 1
                    && _hurd_id.aux.uids[1] != _hurd_id.gen.uids[0])
                   || (_hurd_id.aux.ngids >= 2 && _hurd_id.gen.ngids >= 1
@@ -244,11 +252,6 @@ retry:
       _hurd_id.aux.uids[1] = _hurd_id.gen.uids[0];
       _hurd_id.aux.gids[1] = _hurd_id.gen.gids[0];
       _hurd_id.valid = 0;
-      if (_hurd_id.rid_auth != MACH_PORT_NULL)
-       {
-         __mach_port_deallocate (__mach_task_self (), _hurd_id.rid_auth);
-         _hurd_id.rid_auth = MACH_PORT_NULL;
-       }
 
       err = __auth_makeauth (ports[INIT_PORT_AUTH],
                             NULL, MACH_MSG_TYPE_COPY_SEND, 0,