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:15:06 +0000 (16:15 -0500)
commit5db715e800d9b721f48495a987cd26c25965e836
tree26eaa201b72c436ffcc79c2acbd71e74ee72f0d1
parent04b0e69420e865e56dba55bd09621cb6dc61ec78
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.025312 seconds and 4 git commands to generate.