elf32_checksum acquires either a rdlock or wrlock and then proceeds to call a number of elf_*/gelf_* functions through public interfaces that end up attempting to acquire the same lock, causing a deadlock or SIGABRT.
Fix this by no longer acquiring the rwlock in elf32_checksum. This function is caller-serialized (see THREAD-SAFETY) and must not be called concurrently with any other elfutils library function on the same elf handle or any of its derived handles, so there is no need for locking. Signed-off-by: Aaron Merey <[email protected]> --- libelf/elf32_checksum.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c index a47b307d..34bbc29d 100644 --- a/libelf/elf32_checksum.c +++ b/libelf/elf32_checksum.c @@ -77,14 +77,6 @@ elfw2(LIBELFBITS,checksum) (Elf *elf) || (ident[EI_DATA] == ELFDATA2MSB && BYTE_ORDER == BIG_ENDIAN)); - /* If we don't have native byte order, we will likely need to - convert the data with xlate functions. We do it upfront instead - of relocking mid-iteration. */ - if (!likely (same_byte_order)) - rwlock_wrlock (elf->lock); - else - rwlock_rdlock (elf->lock); - /* Iterate over all sections to find those which are not strippable. */ scn = NULL; while ((scn = INTUSE(elf_nextscn) (elf, scn)) != NULL) @@ -161,7 +153,6 @@ elfw2(LIBELFBITS,checksum) (Elf *elf) } out: - rwlock_unlock (elf->lock); return result; } INTDEF(elfw2(LIBELFBITS,checksum)) -- 2.55.0
