[Bug dynamic-link/28096] New: elf: audit calls that uses static tls might fail

adhemerval.zanella at linaro dot org sourceware-bugzilla@sourceware.org
Fri Jul 16 13:35:40 GMT 2021


https://sourceware.org/bugzilla/show_bug.cgi?id=28096

            Bug ID: 28096
           Summary: elf: audit calls that uses static tls might fail
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: adhemerval.zanella at linaro dot org
  Target Milestone: ---

The following test fails when calling la_activity().  It is because the loader
will load the audit.so modules dependencies, the libc.so will initialize its
TLS static code (for the locales support), but after the audit modules loading,
the loader will initialize the TLS bss with _dl_allocate_tls_init().  It will
then clear the already set TLS variables from libc.so used by audit.so. 

$ cat audit.c 
#define _GNU_SOURCE
#include <ctype.h>
#include <link.h>

volatile int out;

unsigned int la_version
(unsigned int v)
{
  return LAV_CURRENT;
}

void la_activity (uintptr_t* cookie, unsigned int flag)
{
  out = isspace(' ');
}

$ cat main.c 
int main (int argc, char *argv[])
{
  return 0;
}
$ gcc -Wall -fpic -shared audit.c -o audit.so 
$ gcc -Wall main.c -o main
$ LD_AUDIT=./audit.so ./main 
Segmentation fault (core dumped)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list