From: John Baldwin <jhb@FreeBSD.org>
To: Lancelot SIX <lancelot.six@amd.com>, gdb-patches@sourceware.org
Cc: lsix@lancelotsix.com
Subject: Re: [PATCH 0/3] Fix use-after-free in gdb/corelow.c + cleanups
Date: Wed, 31 May 2023 11:32:46 -0700 [thread overview]
Message-ID: <bf5ac1d4-4772-16e2-a9dd-180f0ce82d07@FreeBSD.org> (raw)
In-Reply-To: <20230531160406.3932028-1-lancelot.six@amd.com>
On 5/31/23 9:04 AM, Lancelot SIX via Gdb-patches wrote:
> 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
Patches 2 and 3 look good to me.
--
John Baldwin
prev parent reply other threads:[~2023-05-31 18:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 ` John Baldwin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf5ac1d4-4772-16e2-a9dd-180f0ce82d07@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=lancelot.six@amd.com \
--cc=lsix@lancelotsix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).