public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug libdw/26921] New: dwarf_getalt () not thread-safe
@ 2020-11-19 16:22 mark at klomp dot org
  2020-11-20 19:11 ` [Bug libdw/26921] " woodard at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: mark at klomp dot org @ 2020-11-19 16:22 UTC (permalink / raw)
  To: elfutils-devel

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

            Bug ID: 26921
           Summary: dwarf_getalt () not thread-safe
           Product: elfutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libdw
          Assignee: unassigned at sourceware dot org
          Reporter: mark at klomp dot org
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

When walking a DIE tree getting any attribute values that come from an alt file
(or DWARF5 supplemental file) is not thread-safe. The dwarf_getalt () function
does the following (without any locking):

Dwarf *
dwarf_getalt (Dwarf *main)
{
  /* Only try once.  */
  if (main == NULL || main->alt_dwarf == (void *) -1)
    return NULL;

  if (main->alt_dwarf != NULL)
    return main->alt_dwarf;

  find_debug_altlink (main);

  /* If we found nothing, make sure we don't try again.  */
  if (main->alt_dwarf == NULL)
    {
      main->alt_dwarf = (void *) -1;
      return NULL;
    }

  return main->alt_dwarf;
}

find_debug_altlink will search for the alt file (which is a normal ELF file,
that will be opened with dwarf_begin) if it can be found (and no error occurs).

The rest of the code (except for dwarf_end and an explicit dwarf_setalt call)
doesn't access dwarf->alt_dwarf directly, but all call dwarf_getalt to access
it.

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

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

end of thread, other threads:[~2023-10-06 11:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 16:22 [Bug libdw/26921] New: dwarf_getalt () not thread-safe mark at klomp dot org
2020-11-20 19:11 ` [Bug libdw/26921] " woodard at redhat dot com
2020-11-20 19:13 ` woodard at redhat dot com
2020-11-20 19:17 ` woodard at redhat dot com
2020-11-20 19:20 ` woodard at redhat dot com
2020-11-20 19:26 ` woodard at redhat dot com
2020-11-20 19:43 ` woodard at redhat dot com
2020-11-21 22:00 ` mark at klomp dot org
2020-11-21 23:34 ` woodard at redhat dot com
2020-11-21 23:53 ` mark at klomp dot org
2023-10-06 11:15 ` mark at klomp dot org

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).