public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix use-after-free in gdb/corelow.c + cleanups
@ 2023-05-31 16:04 Lancelot SIX
  2023-05-31 16:04 ` [PATCH 1/3] gdb/corelow.c: fix use-after-free in build_file_mappings Lancelot SIX
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Lancelot SIX @ 2023-05-31 16:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

Hi,

Since a recent change if BFD (014a602b86f "Don't optimise bfd_seek to
same position"), I started to see ASAN report a use-after-free error
when opening some coredumps.

If the original process had some file mapped in its address space that
GDB can open, but calling bfd_check_format on this file fails, GDB would
close the BFD but keep a pointer to it for later use, leading to
use-after-free.

Such scenario can be seen when the original process had some IO pages
mapped from a DRI render node (/dev/dri/renderD$NUM) as it is the case
when offloading compute tasks to AMDGPU devices.

The first patch in this series fixes the use-after-free error.

Once this issue fixed, GDB does show a warning message once for each
region in the process address space where the special file was mapped.
This is un-necessarily noisy, and does not match what is done when GDB
does not find the file to open (exec_find_file returns null).  The
second patch of the series ensures that the warning message can only be
printed once per file.

Finally, the third patch in this series ensures that GDB does not try to
open a file if it has already failed to open it.

Since I am not sure how I can write a simple test to exercise for this
failure, I have not included one.  I have tested this series on a system
using an AMDGPU device, where I originally encountered the problem.

Lancelot SIX (3):
  gdb/corelow.c: fix use-after-free in build_file_mappings
  gdb/corelow.c: avoid repeated warnings in build_file_mappings
  gdb/corelow.c: do not try to reopen a file if open failed once

 gdb/corelow.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)


base-commit: a15891aaea006d06066573449efbda353dd2863e
-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-06-08 13:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 16:04 [PATCH 0/3] Fix use-after-free in gdb/corelow.c + cleanups Lancelot SIX
2023-05-31 16:04 ` [PATCH 1/3] gdb/corelow.c: fix use-after-free in build_file_mappings Lancelot SIX
2023-05-31 18:30   ` John Baldwin
2023-06-01  9:57     ` Andrew Burgess
2023-06-01 10:45       ` [PATCH v2 " Lancelot SIX
2023-06-01 17:05         ` John Baldwin
2023-06-07 14:54         ` Andrew Burgess
2023-06-08 13:22           ` Lancelot SIX
2023-05-31 16:04 ` [PATCH 2/3] gdb/corelow.c: avoid repeated warnings " Lancelot SIX
2023-06-01  9:50   ` Andrew Burgess
2023-05-31 16:04 ` [PATCH 3/3] gdb/corelow.c: do not try to reopen a file if open failed once Lancelot SIX
2023-06-01 10:04   ` Andrew Burgess
2023-05-31 18:32 ` [PATCH 0/3] Fix use-after-free in gdb/corelow.c + cleanups John Baldwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).