From: VMware, Inc <> Date: Thu, 27 Oct 2011 18:44:00 +0000 (-0700) Subject: Leak tls key 0 X-Git-Tag: 2011.10.26-514583~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb644d635e66374b4a069e73ef4cab0683cdef7d;p=thirdparty%2Fopen-vm-tools.git Leak tls key 0 We have a couple of bugs that show system libraries on linux have a nasty habit of destroying the first TLS key, even if they don't own it. This is due to using uninitialized global variables (which default to zero). Rather than expose ourselves to the blame for such bugs, let's just leak the key. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/misc/vthreadBase.c b/open-vm-tools/lib/misc/vthreadBase.c index 64ae08ac4..28b23ad3b 100644 --- a/open-vm-tools/lib/misc/vthreadBase.c +++ b/open-vm-tools/lib/misc/vthreadBase.c @@ -394,6 +394,15 @@ VThreadBaseGetKey(void) #else Bool success = pthread_key_create(&newKey, &VThreadBaseSafeDeleteTLS) == 0; + if (success && newKey == 0) { + /* + * Leak TLS key 0. System libraries have a habit of destroying + * it. See bugs 702818 and 773420. + */ + + success = pthread_key_create(&newKey, + &VThreadBaseSafeDeleteTLS) == 0; + } ASSERT_NOT_IMPLEMENTED(success); #endif