History log of /freebsd-10-stable/lib/libc/gen/tls.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 324617 14-Oct-2017 brooks

MFC r324243:

Remove an unneeded and incorrect memset().

On Variant I TLS architectures (aarch64, arm, mips, powerpc, and riscv)
the __libc_allocate_tls function allocates thread local storage memory
with calloc(). It then copies initialization data over the portions with
non-zero initial values. Before this change it would then pointlessly
zero the already zeroed remainder of the storage. Unfortunately the
calculation was wrong and it would zero TLS_TCB_SIZE (2*sizeof(void *))
additional bytes.

In practice, this overflow only matters if the TLS segment is sized such
that calloc() allocates less than TLS_TCB_SIZE extra memory. Even
then, the likely result will be zeroing part of the next bucket. This
coupled with the impact being confined to Tier II platforms means there
will be no security advisory for this issue.

Reviewed by: kib, dfr
Discussed with: security-officer (delphij)
Found by: CHERI
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12547


# 309485 03-Dec-2016 ngie

MFC r297790:
r297790 (by pfg):

libc: replace 0 with NULL for pointers.

While here also cleanup some surrounding code; particularly
drop some malloc() casts.

Found with devel/coccinelle.


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 234569 22-Apr-2012 jasone

Import jemalloc a8f8d7540d66ddee7337db80c92890916e1063ca (dev branch,
prior to 3.0.0 release). This fixes several bugs related to memory
initialization.

Mangle __jemalloc_a0{malloc,calloc,free}() just like all the other
library-internal symbols in jemalloc, and adjust the tls allocation code
in libc to use the mangled names.


# 234370 17-Apr-2012 jasone

Import jemalloc 9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa (dev branch,
prior to 3.0.0 release) as contrib/jemalloc, and integrate it into libc.
The code being imported by this commit diverged from
lib/libc/stdlib/malloc.c in March 2010, which means that a portion of
the jemalloc 1.0.0 ChangeLog entries are relevant, as are the entries
for all subsequent releases.


# 232582 06-Mar-2012 gonzo

- Switch ARM and MIPS to TLS Variant I
- Fix TLS allocation for Variant I: both rtld and libc allocators
assume that tls_static_space includes space for TLS structure.
So increment calculated static size by the size of it.


# 203946 16-Feb-2010 marcel

The static TLS size as given by tls_static_space includes TLS_TCB_SIZE
bytes of TCB in variant I.


# 178684 29-Apr-2008 gonzo

o Add MIPS to the list of architectures with defined TLS_TCB_ALIGN
o Stick with TLS Variant II for MIPS for the moment.

Approved by: imp


# 166995 25-Feb-2007 kientzle

Don't assert() the TLS allocation requested is big enough; just
fix the argument.

In particular, this is a step towards breaking crt1's dependence on stdio.


# 163118 08-Oct-2006 kmacy

Fix TLS on sparc64 for statically and dynamically linked binaries
Approved by: rwatson (mentor)
Reviewed by: jmg and marcel


# 161827 01-Sep-2006 marcel

Fix style(9) in code copied from rtld.


# 161800 01-Sep-2006 marcel

Fix the variant I allocation for KSE: Allow a larger TCB and assume
that the documented TCB is at the tail of the extended TCB. In other
words, the base of the TCB has a negative offset from the TLS.


# 160711 26-Jul-2006 imp

Remove stale comment about arm


# 157198 28-Mar-2006 davidxu

Allocate space for thread pointer, this allows thread library to access
its pointer from begin, and simplifies _get_curthread() in libthr.


# 143921 21-Mar-2005 davidxu

Use __weak_reference macro to define weak symbols.


# 142959 01-Mar-2005 davidxu

Fix incorrect comment.


# 142560 26-Feb-2005 davidxu

Mark _rtld_allocate_tls and _rtld_free_tls as weak symbols for Variant I
tls.

Reviewed by: dfr


# 135686 23-Sep-2004 cognet

Arbitraly choose the Variant II for arm.


# 134212 23-Aug-2004 dfr

Make sure we allocate at least enough space for the TCB for variant I TLS.

MFC after: 3 days


# 133949 18-Aug-2004 dfr

Always allocate a TLS area even if its empty - libpthread relies on
having a valid %gs when it initialises.

MFC after: 2 days


# 133754 15-Aug-2004 dfr

Add support for TLS in statically linked programs.


# 133064 03-Aug-2004 dfr

Add stubs for TLS functions. These will be replaced at runtime by the
functional versions in rtld.