diff options
author | otto <> | 2021-01-06 19:54:17 +0000 |
---|---|---|
committer | otto <> | 2021-01-06 19:54:17 +0000 |
commit | 7a47c3988c596c6361a22f7e54c95fa3b8629f52 (patch) | |
tree | ce6917eeac88d420d5941f060095fb66f829faea | |
parent | fb99b1b66079e78635372bfe5dcb7a82ab2c36aa (diff) | |
download | openbsd-7a47c3988c596c6361a22f7e54c95fa3b8629f52.tar.gz openbsd-7a47c3988c596c6361a22f7e54c95fa3b8629f52.tar.bz2 openbsd-7a47c3988c596c6361a22f7e54c95fa3b8629f52.zip |
Fix two issues related to thread private data in asr.
- setting up asr in single thread mode and then starting threads using asr
would lead to multiple threads sharing the same resolver.
- destruction of a thread that has been using asr would leak data.
Problem originally reported by Alexey Sokolov and Uli Schlachter.
ok kettenis@
-rw-r--r-- | src/lib/libc/include/thread_private.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h index 98dfaa6322..237c3fbd03 100644 --- a/src/lib/libc/include/thread_private.h +++ b/src/lib/libc/include/thread_private.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: thread_private.h,v 1.35 2019/02/13 13:22:14 mpi Exp $ */ | 1 | /* $OpenBSD: thread_private.h,v 1.36 2021/01/06 19:54:17 otto Exp $ */ |
2 | 2 | ||
3 | /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ | 3 | /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ |
4 | 4 | ||
@@ -98,7 +98,8 @@ struct thread_callbacks { | |||
98 | void (*tc_mutex_destroy)(void **); | 98 | void (*tc_mutex_destroy)(void **); |
99 | void (*tc_tag_lock)(void **); | 99 | void (*tc_tag_lock)(void **); |
100 | void (*tc_tag_unlock)(void **); | 100 | void (*tc_tag_unlock)(void **); |
101 | void *(*tc_tag_storage)(void **, void *, size_t, void *); | 101 | void *(*tc_tag_storage)(void **, void *, size_t, void (*)(void *), |
102 | void *); | ||
102 | __pid_t (*tc_fork)(void); | 103 | __pid_t (*tc_fork)(void); |
103 | __pid_t (*tc_vfork)(void); | 104 | __pid_t (*tc_vfork)(void); |
104 | void (*tc_thread_release)(struct pthread *); | 105 | void (*tc_thread_release)(struct pthread *); |
@@ -142,6 +143,7 @@ __END_HIDDEN_DECLS | |||
142 | #define _THREAD_PRIVATE_MUTEX_LOCK(name) do {} while (0) | 143 | #define _THREAD_PRIVATE_MUTEX_LOCK(name) do {} while (0) |
143 | #define _THREAD_PRIVATE_MUTEX_UNLOCK(name) do {} while (0) | 144 | #define _THREAD_PRIVATE_MUTEX_UNLOCK(name) do {} while (0) |
144 | #define _THREAD_PRIVATE(keyname, storage, error) &(storage) | 145 | #define _THREAD_PRIVATE(keyname, storage, error) &(storage) |
146 | #define _THREAD_PRIVATE_DT(keyname, storage, dt, error) &(storage) | ||
145 | #define _MUTEX_LOCK(mutex) do {} while (0) | 147 | #define _MUTEX_LOCK(mutex) do {} while (0) |
146 | #define _MUTEX_UNLOCK(mutex) do {} while (0) | 148 | #define _MUTEX_UNLOCK(mutex) do {} while (0) |
147 | #define _MUTEX_DESTROY(mutex) do {} while (0) | 149 | #define _MUTEX_DESTROY(mutex) do {} while (0) |
@@ -168,7 +170,12 @@ __END_HIDDEN_DECLS | |||
168 | #define _THREAD_PRIVATE(keyname, storage, error) \ | 170 | #define _THREAD_PRIVATE(keyname, storage, error) \ |
169 | (_thread_cb.tc_tag_storage == NULL ? &(storage) : \ | 171 | (_thread_cb.tc_tag_storage == NULL ? &(storage) : \ |
170 | _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \ | 172 | _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \ |
171 | &(storage), sizeof(storage), error)) | 173 | &(storage), sizeof(storage), NULL, (error))) |
174 | |||
175 | #define _THREAD_PRIVATE_DT(keyname, storage, dt, error) \ | ||
176 | (_thread_cb.tc_tag_storage == NULL ? &(storage) : \ | ||
177 | _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \ | ||
178 | &(storage), sizeof(storage), (dt), (error))) | ||
172 | 179 | ||
173 | /* | 180 | /* |
174 | * Macros used in libc to access mutexes. | 181 | * Macros used in libc to access mutexes. |