This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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
correct.

Installed on master.

Thanks,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]