]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: Fix deadlock in __libelf_readall
authorHeather McIntyre <hsm2@rice.edu>
Tue, 10 Oct 2023 13:42:47 +0000 (15:42 +0200)
committerAaron Merey <amerey@redhat.com>
Tue, 4 Jun 2024 19:08:55 +0000 (15:08 -0400)
* libelf/elf_readall.c (__libelf_readall): Move rwlock_unlock
before libelf_acquire_all.

Signed-off-by: Heather S. McIntyre <hsm2@rice.edu>
Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf_readall.c

index d0f9a28cc59ea192165391babb31eed951a771ed..2d62d4471ccca180a813e0c655af80ea44b8f184 100644 (file)
@@ -84,6 +84,7 @@ __libelf_readall (Elf *elf)
 
       /* If this is an archive and we have derived descriptors get the
         locks for all of them.  */
+      rwlock_unlock(elf->lock); // lock will be reacquired next line
       libelf_acquire_all (elf);
 
       if (elf->maximum_size == ~((size_t) 0))
@@ -141,10 +142,8 @@ __libelf_readall (Elf *elf)
        __libelf_seterrno (ELF_E_NOMEM);
 
       /* Free the locks on the children.  */
-      libelf_release_all (elf);
+      libelf_release_all (elf); // lock is released
     }
 
-  rwlock_unlock (elf->lock);
-
   return (char *) elf->map_address;
 }