[Bug libdw/26921] New: dwarf_getalt () not thread-safe

mark at klomp dot org sourceware-bugzilla@sourceware.org
Thu Nov 19 16:22:32 GMT 2020


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.


More information about the Elfutils-devel mailing list