public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/15] Dynamic TLS related data race fixes
@ 2021-02-15 11:56 Szabolcs Nagy
  2021-02-15 11:56 ` [PATCH 01/15] aarch64: free tlsdesc data on dlclose [BZ #27403] Szabolcs Nagy
                   ` (17 more replies)
  0 siblings, 18 replies; 40+ messages in thread
From: Szabolcs Nagy @ 2021-02-15 11:56 UTC (permalink / raw)
  To: libc-alpha

This series is trying to address some long standing dynamic
linker races:

19329 - race between tls access, pthread_create and dlopen
27111 - race between tls access, pthread_create and dlclose
21349 - a lazy symbol binding race (not related to TLS)
27137 - lazy tlsdesc relocation on x86 is racy

and there were a number of minor issues uncovered:

27135 - dtv gaps are not reused
27136 - dtv off-by-1 error,
27403 - aarch64 memleak on dlclose

there are related issues that are not fixed, but tried to
not make the situation worse:

16133 - tls access is not as-safe
16134 - tls allocation aborts on oom
27112 - generation count may overflow on 32 bit targets

some of the patches can be handled independently.

The set is also available in the nsz/bug19329 branch.

There are new test cases that are early in the series for now
so they can be run before the fixes.

A common theme between the races is that the GL(dl_load_lock)
lock protects various dynamic linker shared global state that
are written under that lock, but in various situations (lazy
binding, tls access, thread creation) they are read without
the lock.

An earlier analysis about bug 19329
https://sourceware.org/pipermail/libc-alpha/2020-December/121090.html

In some cases atomics is used for synchronization, this means
all accesses to that object has to be atomic even if that's
behind a lock. I think this is unnecessary and can be confusing:
https://sourceware.org/pipermail/libc-alpha/2020-December/121200.html

This patchset does not try to turn non-racy read into relaxed
atomic read.

The removal of lazy tlsdesc relocation may allow further changes
at the end.  The x86 changes were not excessively tested. I ran
the glibc tests on x86_64, i386 and aarch64 linux.

Maninder Singh (1):
  elf: Fix data race in _dl_name_match_p [BZ #21349]

Szabolcs Nagy (14):
  aarch64: free tlsdesc data on dlclose [BZ #27403]
  Add test case for [BZ #19329]
  Add a DTV setup test [BZ #27136]
  elf: Fix a DTV setup issue [BZ #27136]
  elf: Fix comments and logic in _dl_add_to_slotinfo
  elf: Refactor _dl_update_slotinfo to avoid use after free
  elf: Fix data races in pthread_create and TLS access [BZ #19329]
  elf: Use relaxed atomics for racy accesses [BZ #19329]
  elf: Fix DTV gap reuse logic [BZ #27135]
  x86_64: Avoid lazy relocation of tlsdesc [BZ #27137]
  i386: Avoid lazy relocation of tlsdesc [BZ #27137]
  x86_64: Remove lazy tlsdesc relocation related code
  i386: Remove lazy tlsdesc relocation related code
  elf: Remove lazy tlsdesc relocation related code

 elf/dl-close.c                 |  26 ++--
 elf/dl-load.c                  |  18 ++-
 elf/dl-misc.c                  |   4 +-
 elf/dl-open.c                  |  15 +--
 elf/dl-tls.c                   | 133 +++++++++++--------
 elf/tlsdeschtab.h              |  53 +-------
 nptl/Makefile                  |  25 +++-
 nptl/tst-tls7.c                |  69 ++++++++++
 nptl/tst-tls7mod-dep.c         |   1 +
 nptl/tst-tls7mod.c             |   1 +
 nptl/tst-tls8.c                |  96 ++++++++++++++
 nptl/tst-tls8mod-bad.c         |   2 +
 sysdeps/aarch64/dl-lookupcfg.h |  27 ++++
 sysdeps/aarch64/tlsdesc.c      |   1 -
 sysdeps/arm/tlsdesc.c          |   1 -
 sysdeps/i386/dl-machine.h      |  76 +++++------
 sysdeps/i386/dl-tlsdesc.S      | 156 ----------------------
 sysdeps/i386/dl-tlsdesc.h      |   6 +-
 sysdeps/i386/tlsdesc.c         | 230 ---------------------------------
 sysdeps/x86_64/dl-machine.h    |  19 ++-
 sysdeps/x86_64/dl-tlsdesc.S    | 104 ---------------
 sysdeps/x86_64/dl-tlsdesc.h    |   4 +-
 sysdeps/x86_64/tlsdesc.c       | 108 ----------------
 23 files changed, 393 insertions(+), 782 deletions(-)
 create mode 100644 nptl/tst-tls7.c
 create mode 100644 nptl/tst-tls7mod-dep.c
 create mode 100644 nptl/tst-tls7mod.c
 create mode 100644 nptl/tst-tls8.c
 create mode 100644 nptl/tst-tls8mod-bad.c
 create mode 100644 sysdeps/aarch64/dl-lookupcfg.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2021-04-09 14:55 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 11:56 [PATCH 00/15] Dynamic TLS related data race fixes Szabolcs Nagy
2021-02-15 11:56 ` [PATCH 01/15] aarch64: free tlsdesc data on dlclose [BZ #27403] Szabolcs Nagy
2021-04-01 12:57   ` Adhemerval Zanella
2021-04-06 13:43     ` Szabolcs Nagy
2021-04-06 16:52       ` Adhemerval Zanella
2021-02-15 11:56 ` [PATCH 02/15] elf: Fix data race in _dl_name_match_p [BZ #21349] Szabolcs Nagy
2021-04-01 14:01   ` Adhemerval Zanella
2021-04-06 16:41     ` Szabolcs Nagy
2021-02-15 11:57 ` [PATCH 03/15] Add test case for [BZ #19329] Szabolcs Nagy
2021-04-02 19:10   ` Adhemerval Zanella
2021-02-15 11:59 ` [PATCH 04/15] Add a DTV setup test [BZ #27136] Szabolcs Nagy
2021-04-02 19:35   ` Adhemerval Zanella
2021-02-15 11:59 ` [PATCH 05/15] elf: Fix a DTV setup issue " Szabolcs Nagy
2021-04-02 19:46   ` Adhemerval Zanella
2021-02-15 11:59 ` [PATCH 06/15] elf: Fix comments and logic in _dl_add_to_slotinfo Szabolcs Nagy
2021-04-02 20:50   ` Adhemerval Zanella
2021-04-06 15:48     ` Szabolcs Nagy
2021-04-06 17:47       ` Adhemerval Zanella
2021-04-07  7:57         ` Szabolcs Nagy
2021-04-07 14:20           ` Adhemerval Zanella
2021-02-15 12:00 ` [PATCH 07/15] elf: Refactor _dl_update_slotinfo to avoid use after free Szabolcs Nagy
2021-04-06 19:40   ` Adhemerval Zanella
2021-04-07  8:01     ` Szabolcs Nagy
2021-04-07 14:28       ` Adhemerval Zanella
2021-04-07 14:36         ` Adhemerval Zanella
2021-04-07 17:05   ` Adhemerval Zanella
2021-02-15 12:01 ` [PATCH 08/15] elf: Fix data races in pthread_create and TLS access [BZ #19329] Szabolcs Nagy
2021-02-15 12:01 ` [PATCH 09/15] elf: Use relaxed atomics for racy accesses " Szabolcs Nagy
2021-02-15 12:01 ` [PATCH 10/15] elf: Fix DTV gap reuse logic [BZ #27135] Szabolcs Nagy
2021-02-15 12:02 ` [PATCH 11/15] x86_64: Avoid lazy relocation of tlsdesc [BZ #27137] Szabolcs Nagy
2021-04-09  0:14   ` Ben Woodard
2021-04-09 13:38     ` Szabolcs Nagy
2021-04-09 14:55       ` Ben Woodard
2021-02-15 12:02 ` [PATCH 12/15] i386: " Szabolcs Nagy
2021-02-15 12:02 ` [PATCH 13/15] x86_64: Remove lazy tlsdesc relocation related code Szabolcs Nagy
2021-02-15 12:03 ` [PATCH 14/15] i386: " Szabolcs Nagy
2021-02-15 12:03 ` [PATCH 15/15] elf: " Szabolcs Nagy
2021-02-15 12:08 ` [PATCH 03/15] Add test case for [BZ #19329] Szabolcs Nagy
2021-02-15 12:08 ` [PATCH 06/15] elf: Fix comments and logic in _dl_add_to_slotinfo Szabolcs Nagy
     [not found] ` <CGME20210215115731epcas5p45614957debad2f679230d0bd1efbd57f@epcms5p7>
2021-02-15 12:11   ` [PATCH 02/15] elf: Fix data race in _dl_name_match_p [BZ #21349] Maninder Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).