[PATCH] libdwfl: Fix fd leak/closing wrong fd after dwfl_core_file_report()

Mark Wielaard mark@klomp.org
Fri Aug 9 21:12:00 GMT 2019

Hi Omar,

On Mon, 2019-08-05 at 03:40 -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> dwfl_segment_report_module() (used only by dwfl_core_file_report())
> opens a file descriptor and/or an Elf handle, reports a module, and
> assigns mod->main.elf. However, it doesn't assign mod->main.fd, so it
> is
> left as 0. This causes two problems:
> 1. We leak the file descriptor for the module.
> 2. When we free the module, we close file descriptor 0 (stdin).
> Fix it by assigning mod->main.fd.
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Very nice find!

Using strace or valgrind --track-fds=yes on eu-stack --core it is easy
to see what is going wrong. Luckily your fix is easy and obviously

Installed on master.



More information about the Elfutils-devel mailing list