]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: Make pthread_[gs]etspecific not check for key validity
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 13 Feb 2022 23:15:13 +0000 (00:15 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 14 Feb 2022 18:29:02 +0000 (19:29 +0100)
Since __pthread_key_create might be concurrently reallocating the
__pthread_key_destructors array, it's not safe to access it without the
mutex held. Posix explicitly says we are allowed to prefer performance
over error detection.

sysdeps/htl/pt-getspecific.c
sysdeps/htl/pt-setspecific.c

index af1161206afe172895ad572e33138c881c66ff5f..a9dfd8a77512731e258d09d67570d749140de029 100644 (file)
@@ -25,8 +25,7 @@ __pthread_getspecific (pthread_key_t key)
 {
   struct __pthread *self;
 
-  if (key < 0 || key >= __pthread_key_count
-      || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+  if (key < 0 || key >= __pthread_key_count)
     return NULL;
 
   self = _pthread_self ();
index 982d25d0128ee7ead8950d2fe912b42daefee99e..d201416d5d5c51e860d9c71ff74cbcac677f053c 100644 (file)
@@ -25,8 +25,7 @@ __pthread_setspecific (pthread_key_t key, const void *value)
 {
   struct __pthread *self = _pthread_self ();
 
-  if (key < 0 || key >= __pthread_key_count
-      || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+  if (key < 0 || key >= __pthread_key_count)
     return EINVAL;
 
   if (key >= self->thread_specifics_size)