[PATCH] Fix threading support in talloc_stackframe
Ralph Böhme
slow at samba.org
Wed Jul 4 12:53:40 UTC 2018
Hi!
Just stumpled across this nice little crash in talloc_stackframe after enabling
thread-safety and using it in a vfs_xattr_tdb patch.
Please review carefully and push if happy. Thanks!
-slow
--
Ralph Boehme, Samba Team https://samba.org/
Samba Developer, SerNet GmbH https://sernet.de/en/samba/
GPG Key Fingerprint: FAE2 C608 8A24 2520 51C5
59E4 AA1E 9B71 2639 9E46
-------------- next part --------------
From 6d8c745a1bab7637e697f4d8d9b7f10f5750ca35 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 3 Jul 2018 15:30:33 +0200
Subject: [PATCH] lib: smb_threads: fix access before init bug
talloc_stackframe_internal() calls SMB_THREAD_GET_TLS(global_ts) which
calls smb_get_tls_pthread() in the POSIX pthread wrapper implementation.
If SMB_THREAD_SET_TLS() hasn't been called before, global_ts is NULL and
smb_get_tls_pthread dereferences it so it crashes.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13505
Signed-off-by: Ralph Boehme <slow at samba.org>
---
lib/util/smb_threads.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/util/smb_threads.h b/lib/util/smb_threads.h
index 9a096167743..67d05b8c411 100644
--- a/lib/util/smb_threads.h
+++ b/lib/util/smb_threads.h
@@ -119,6 +119,9 @@ static int smb_set_tls_pthread(void *pkey, const void *pval, const char *locatio
\
static void *smb_get_tls_pthread(void *pkey, const char *location) \
{ \
+ if (pkey == NULL) { \
+ return NULL; \
+ } \
return pthread_getspecific(*(pthread_key_t *)pkey); \
} \
\
--
2.13.6
More information about the samba-technical
mailing list