]> git.ipfire.org Git - thirdparty/elfutils.git/commit
elf_getdata_rawchunk.c: Fix dummy chunk insertion race condition
authorAaron Merey <amerey@redhat.com>
Mon, 28 Jul 2025 20:32:28 +0000 (16:32 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 5 Sep 2025 16:41:48 +0000 (12:41 -0400)
commit20b0dae7eb2ce48ee9fb5d4f41352b2c99efd066
tree9c212fa6a8ab2274335aec97dd71e5e3fefd6575
parent680eb3021e529023c6b9f942a1a8cad1eb933544
elf_getdata_rawchunk.c: Fix dummy chunk insertion race condition

When elf_getdata_rawchunk aquires a new chunk for the first time, it
inserts a stack-allocated dummy chunk into a search_tree with a rdlock
held.  When the real chunk is prepared to replace the dummy chunk, the
rdlock is released and a wrlock is then held while replacing the
dummy with the real chunk.

Before the wrlock is held, other threads could incorrectly acquire the
dummy chunk as if it were a real chunk.

Fix this by holding a wrlock throughout elf_getdata_rawchunk.

Signed-off-by: Aaron Merey <amerey@redhat.com>
libelf/elf_getdata_rawchunk.c