about summary refs log tree commit diff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-04 00:06:01 +0000
committerRoland McGrath <roland@gnu.org>1996-01-04 00:06:01 +0000
commit6df1b2474adfc23c9cfff5a4496108bea0c37511 (patch)
tree48bd35ba5b0d766560edde694efec2b791ada613 /sysdeps/mach/hurd
parent71733723fb421bd54467d1a27096463ed1dcc2ed (diff)
downloadglibc-6df1b2474adfc23c9cfff5a4496108bea0c37511.tar.gz
glibc-6df1b2474adfc23c9cfff5a4496108bea0c37511.tar.xz
glibc-6df1b2474adfc23c9cfff5a4496108bea0c37511.zip
Rewritten. cvs/libc-960103
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/fork.c22
-rw-r--r--sysdeps/mach/hurd/jmp-unwind.c6
-rw-r--r--sysdeps/mach/hurd/setgid.c27
3 files changed, 35 insertions, 20 deletions
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
index 25279645ee..6fadb3d97d 100644
--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -121,7 +121,6 @@ __fork (void)
 	__spin_lock (&_hurd_ports[i].lock);
       ports_locked = 1;
 
-      *(volatile task_t *) &__mach_task_self_; /* XXX work around kernel bug */
 
       /* Stop all other threads while copying the address space,
 	 so nothing changes.  */
@@ -130,6 +129,25 @@ __fork (void)
         {
           stopped = 1;
 
+#define XXX_KERNEL_PAGE_FAULT_BUG /* XXX work around page fault bug in mk */
+
+#ifdef XXX_KERNEL_PAGE_FAULT_BUG
+	  /* Gag me with a pitchfork.
+	     The bug scenario is this:
+
+	     - The page containing __mach_task_self_ is paged out.
+	     - The signal thread was faulting on that page when we
+	       suspended it via proc_dostop.  It holds some lock, or set
+	       some busy bit, or somesuch.
+	     - Now this thread faults on that same page.
+	     - GRATUIOUS DEADLOCK
+
+	     We can break the deadlock by aborting the thread that faulted
+	     first, which if the bug happened was the signal thread because
+	     it is the only other thread and we just suspended it.
+	     */
+	  __thread_abort (_hurd_msgport_thread);
+#endif
 	  /* Create the child task.  It will inherit a copy of our memory.  */
 	  err = __task_create (__mach_task_self (), 1, &newtask);
         }
diff --git a/sysdeps/mach/hurd/jmp-unwind.c b/sysdeps/mach/hurd/jmp-unwind.c
index 822501f8e5..20ca5f8aa6 100644
--- a/sysdeps/mach/hurd/jmp-unwind.c
+++ b/sysdeps/mach/hurd/jmp-unwind.c
@@ -1,5 +1,5 @@
 /* _longjmp_unwind -- Clean up stack frames unwound by longjmp.  Hurd version.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -18,8 +18,9 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <setjmp.h>
-#include <hurd/signal.h>
 #include <hurd/userlink.h>
+#include <hurd/signal.h>
+#include <hurd/sigpreempt.h>
 #include <assert.h>
 
 
@@ -36,7 +37,6 @@ _longjmp_unwind (jmp_buf env, int val)
 {
   struct hurd_sigstate *ss = _hurd_self_sigstate ();
   struct hurd_userlink *link;
-  struct hurd_signal_preempter **p;
 
   /* All access to SS->active_resources must take place inside a critical
      section where signal handlers cannot run.  */
diff --git a/sysdeps/mach/hurd/setgid.c b/sysdeps/mach/hurd/setgid.c
index b2d9313307..ca493a4f7b 100644
--- a/sysdeps/mach/hurd/setgid.c
+++ b/sysdeps/mach/hurd/setgid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -46,21 +46,26 @@ DEFUN(__setgid, (gid), gid_t gid)
       gid_t *newgen, *newaux, auxbuf[2];
       size_t ngen, naux;
 
-      newaux = _hurd_id.aux.gids;
-      naux = _hurd_id.aux.ngids;
       if (_hurd_id.gen.ngids == 0)
 	{
 	  /* No effective gids now.  The new set will be just GID.  */
 	  newgen = &gid;
 	  ngen = 1;
 	}
-      else if (_hurd_id.gen.gids[0] == 0)
+      else
 	{
-	  /* We are root; set the effective, real, and saved to GID.  */
 	  _hurd_id.gen.gids[0] = gid;
 	  _hurd_id.valid = 0;
 	  newgen = _hurd_id.gen.gids;
 	  ngen = _hurd_id.gen.ngids;
+	}
+
+      newaux = _hurd_id.aux.gids;
+      naux = _hurd_id.aux.ngids;
+      if (_hurd_id.gen.nuids > 0 && _hurd_id.gen.uids[0] == 0)
+	{
+	  /* We are root; set the real and saved IDs too.  */
+	  _hurd_id.valid = 0;
 	  if (_hurd_id.aux.ngids < 2)
 	    {
 	      newaux = auxbuf;
@@ -68,20 +73,12 @@ DEFUN(__setgid, (gid), gid_t gid)
 	    }
 	  newaux[0] = newaux[1] = gid;
 	}
-      else
-	{
-	  /* We are not root; just change the effective GID.  */
-	  _hurd_id.gen.gids[0] = gid;
-	  _hurd_id.valid = 0;
-	  newgen = _hurd_id.gen.gids;
-	  ngen = _hurd_id.gen.ngids;
-	}
 
       err = __USEPORT (AUTH, __auth_makeauth
 		       (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+			_hurd_id.gen.uids, _hurd_id.gen.nuids,
+			_hurd_id.aux.uids, _hurd_id.aux.nuids,
 			newgen, ngen, newaux, naux,
-			_hurd_id.gen.gids, _hurd_id.gen.ngids,
-			_hurd_id.aux.gids, _hurd_id.aux.ngids,
 			&newauth));
     }
   __mutex_unlock (&_hurd_id.lock);