Hurd: Missing critical region locks.
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 10 May 2012 20:00:01 +0000 (13:00 -0700)
committerRoland McGrath <roland@hack.frob.com>
Thu, 10 May 2012 22:57:23 +0000 (15:57 -0700)
ChangeLog
hurd/hurd/fd.h
sysdeps/mach/hurd/dirfd.c
sysdeps/mach/hurd/opendir.c

index 0d93e03af9d2d1a3ac7edfb90912e31d021e0b2e..83afde7d03293d08dddd6a5709ac89cc6a7e6479 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-05-10  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
+        * hurd/hurd/fd.h (_hurd_fd_get): Call HURD_CRITICAL_BEGIN/
+        HURD_CRITICAL_END around holding _hurd_dtable_lock.
+        * sysdeps/mach/hurd/dirfd (dirfd): Likewise.
+        * sysdeps/mach/hurd/opendir.c (_hurd_fd_opendir): Call
+        HURD_CRITICAL_BEGIN/HURD_CRITICAL_END around holding
+        d->port.lock.
+
         * hurd/catch-signal.c (hurd_catch_signal): Use sigsetjmp/siglongjmp
         instead of setjmp/longjmp to restore the signal mask.  Call sigsetjmp
         when handler == SIG_ERR, not when handler != SIG_ERR.
index 5044f977fb55b66c020d526626c9251572de6978..6a79738cb60f30c29873eda3645e78feec225fb4 100644 (file)
@@ -63,6 +63,7 @@ _hurd_fd_get (int fd)
 {
   struct hurd_fd *descriptor;
 
+  HURD_CRITICAL_BEGIN;
   __mutex_lock (&_hurd_dtable_lock);
   if (fd < 0 || fd >= _hurd_dtablesize)
     descriptor = NULL;
@@ -85,6 +86,7 @@ _hurd_fd_get (int fd)
        }
     }
   __mutex_unlock (&_hurd_dtable_lock);
+  HURD_CRITICAL_END;
 
   return descriptor;
 }
index 587ae7b2f159541418b55b02368539e3fb774239..42dbc78839b5aa7cb201f1c36b303e281406ab27 100644 (file)
@@ -1,5 +1,5 @@
 /* dirfd -- Return the file descriptor used by a DIR stream.  Hurd version.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 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
@@ -25,6 +25,8 @@ int
 dirfd (DIR *dirp)
 {
   int fd;
+
+  HURD_CRITICAL_BEGIN;
   __mutex_lock (&_hurd_dtable_lock);
   for (fd = 0; fd < _hurd_dtablesize; ++fd)
     if (_hurd_dtable[fd] == dirp->__fd)
@@ -35,6 +37,7 @@ dirfd (DIR *dirp)
       fd = -1;
     }
   __mutex_unlock (&_hurd_dtable_lock);
+  HURD_CRITICAL_END;
 
   return fd;
 }
index 217d4c85dd270370daf47459bb27147669703b3c..c71cb18a658fd8fff9b7fe0357188fc48737b622 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993,1994,1995,1996,1997,1998,2001,2003,2005,2006
-       Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 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
@@ -50,9 +49,11 @@ _hurd_fd_opendir (struct hurd_fd *d)
     return NULL;
 
   /* Set the descriptor to close on exec. */
+  HURD_CRITICAL_BEGIN;
   __spin_lock (&d->port.lock);
   d->flags |= FD_CLOEXEC;
   __spin_unlock (&d->port.lock);
+  HURD_CRITICAL_END;
 
   dirp->__fd = d;
   dirp->__data = dirp->__ptr = NULL;