]> sourceware.org Git - glibc.git/commitdiff
hurd: Fix auth port leak
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 2 Jan 2022 03:08:11 +0000 (04:08 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 4 Jan 2022 00:14:41 +0000 (01:14 +0100)
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.

hurd/hurdexec.c

index 3dc61431d578ee35826cf359e190370ddbe192d0..5b27f1861b2d5199a2228de81247c1bf0c6558a2 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,
This page took 0.043972 seconds and 5 git commands to generate.