Fix: libc wrapper: use initial-exec for malloc_nesting TLS
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 Jan 2024 18:36:29 +0000 (13:36 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 6 Feb 2024 21:14:49 +0000 (16:14 -0500)
commit49400d96e137c653092cf42177decbd7573fcfcf
treec70fd4c95db6d420ea8d1d67c826322625e5f493
parent89a8858dc6fdaf6c094d9038db79fbc61469ccef
Fix: libc wrapper: use initial-exec for malloc_nesting TLS

Use the initial-exec TLS model for the malloc_nesting nesting guard
variable to ensure that the glibc implementation of the TLS access don't
trigger infinite recursion by calling the memory allocator wrapper
functions, which can happen with global-dynamic.

Considering that the libc wrapper is meant to be loaded with LD_PRELOAD
anyway (never with dlopen(3)), we always expect the libc to have enough
space to hold the malloc_nesting variable.

In addition to change the malloc_nesting from global-dynamic to
initial-exec, this removes the URCU TLS compatibility layer from the
libc wrapper, which is a good thing: this compatibility layer relies
on pthread key and calloc internally, which makes it a bad fit for TLS
accesses guarding access to malloc wrappers, due to possible infinite
recursion.

Link: https://lists.lttng.org/pipermail/lttng-dev/2024-January/030697.html
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I72c42bc09c1a06e2922b184b85abeb9c94200ee2
src/lib/lttng-ust-libc-wrapper/lttng-ust-malloc.c
This page took 0.02497 seconds and 4 git commands to generate.