From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH for-5.0] dump: Fix writing of ELF section
Date: Tue, 24 Mar 2020 18:49:29 +0100 [thread overview]
Message-ID: <CAMxuvawMhTCHkx1CA7XG6watFre8SzHn7eHVQR7sYSXMmXiGBA@mail.gmail.com> (raw)
In-Reply-To: <20200324173630.12221-1-peter.maydell@linaro.org>
Hi
On Tue, Mar 24, 2020 at 6:36 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> In write_elf_section() we set the 'shdr' pointer to point to local
> structures shdr32 or shdr64, which we fill in to be written out to
> the ELF dump. Unfortunately the address we pass to fd_write_vmcore()
> has a spurious '&' operator, so instead of writing out the section
> header we write out the literal pointer value followed by whatever is
> on the stack after the 'shdr' local variable.
>
> Pass the correct address into fd_write_vmcore().
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> I have not tested this because I can't reproduce the conditions
> under which we try to actually use write_elf_section() (they
> must be rare, because currently we produce a bogus ELF file
> for this code path). In dump_init() s->list.num must be
> at least UINT16_MAX-1, which I think means it has to be a
> paging-enabled dump and the guest's page table must be
> extremely fragmented ?
yeah, I can't help either without spending more time playing with it,
but the fix looks good nonetheless.
> ---
> dump/dump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 6fb6e1245ad..22ed1d3b0d4 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -364,7 +364,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp)
> shdr = &shdr64;
> }
>
> - ret = fd_write_vmcore(&shdr, shdr_size, s);
> + ret = fd_write_vmcore(shdr, shdr_size, s);
> if (ret < 0) {
> error_setg_errno(errp, -ret,
> "dump: failed to write section header table");
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-03-24 17:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 17:36 [PATCH for-5.0] dump: Fix writing of ELF section Peter Maydell
2020-03-24 17:38 ` Peter Maydell
2020-03-24 17:49 ` Marc-André Lureau [this message]
2020-04-03 18:26 ` Peter Maydell
2020-04-03 20:55 ` Philippe Mathieu-Daudé
2020-04-04 9:07 ` Peter Maydell
2020-04-06 10:01 ` Peter Maydell
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=CAMxuvawMhTCHkx1CA7XG6watFre8SzHn7eHVQR7sYSXMmXiGBA@mail.gmail.com \
--to=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 NNTP newsgroup(s).