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:17:20 +0000 (16:17 -0500)
commit6d564f0a194ffc655061fe1bd35333fbfcafb488
treeb1e10813d9af4bf89262e60db7a7a3425e581790
parent32b9b7ba68b8705ce6c85e0342069ae6c75b790f
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
liblttng-ust-libc-wrapper/lttng-ust-malloc.c
This page took 0.024573 seconds and 4 git commands to generate.