]> git.ipfire.org Git - thirdparty/glibc.git/commit - elf/dl-find_object.c
elf: Fix fences in _dl_find_object_update (bug 28745)
authorFlorian Weimer <fweimer@redhat.com>
Fri, 7 Jan 2022 12:21:57 +0000 (13:21 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 7 Jan 2022 12:21:57 +0000 (13:21 +0100)
commitacbaad31e8ea10fce8b9c0aef58afb388bf7489d
treeeb8a5902a2080aa094a823ef02a64f78c2da4d71
parentd5b0046e3ddf8ea82a3eff74068b8fd2665b98db
elf: Fix fences in _dl_find_object_update (bug 28745)

As explained in Hans Boehm, Can Seqlocks Get Along with Programming
Language Memory Models?, an acquire fence is needed in
_dlfo_read_success.  The lack of a fence resulted in an observable
bug on powerpc64le compile-time load reordering.

The fence in _dlfo_mappings_begin_update has been reordered, turning
the fence/store sequence into a release MO store equivalent.

Relaxed MO loads are used on the reader side, and relaxed MO stores
on the writer side for the shared data, to avoid formal data races.
This is just to be conservative; it should not actually be necessary
given how the data is used.

This commit also fixes the test run time.  The intent was to run it
for 3 seconds, but 0.3 seconds was enough to uncover the bug very
occasionally (while 3 seconds did not reliably show the bug on every
test run).

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
elf/dl-find_object.c
elf/dl-find_object.h
elf/tst-dl_find_object-threads.c