Further harden glibc malloc metadata against 1-byte overflows.
[glibc.git] / nptl / createthread.c
blob6c67b7e74e95e2dcb5ba32e41657949514c3f668
1 /* Low-level thread creation for NPTL. Stub version.
2 Copyright (C) 2014-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* See the comments in pthread_create.c for the requirements for these
20 two macros and the create_thread function. */
22 #define START_THREAD_DEFN \
23 static void __attribute__ ((noreturn)) start_thread (void)
24 #define START_THREAD_SELF THREAD_SELF
26 static int
27 create_thread (struct pthread *pd, const struct pthread_attr *attr,
28 bool *stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran)
30 /* If the implementation needs to do some tweaks to the thread after
31 it has been created at the OS level, it can set STOPPED_START here. */
33 pd->stopped_start = *stopped_start;
34 if (__glibc_unlikely (*stopped_start))
35 /* See CONCURRENCY NOTES in nptl/pthread_create.c. */
36 lll_lock (pd->lock, LLL_PRIVATE);
38 return ENOSYS;
40 /* It's started now, so if we fail below, we'll have to cancel it
41 and let it clean itself up. */
42 *thread_ran = true;
44 return 0;