From: Peter Maydell <peter.maydell@linaro.org>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Viktor Prutyanov <viktor.prutyanov@phystech.edu>, qemu-devel@nongnu.org
Subject: Re: [PATCH 4/7] contrib/elf2dmp: Use lduw_le_p() to read PDB
Date: Mon, 4 Mar 2024 17:56:58 +0000 [thread overview]
Message-ID: <CAFEAcA8TmKAPU_egO5tkHHFEodSJX_yssqx9kWaq=+tS1mrxnQ@mail.gmail.com> (raw)
In-Reply-To: <20240303-elf2dmp-v1-4-bea6649fe3e6@daynix.com>
On Sun, 3 Mar 2024 at 10:52, Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> This resolved UBSan warnings.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> contrib/elf2dmp/pdb.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
> index 40991f5f4c34..2541234205c3 100644
> --- a/contrib/elf2dmp/pdb.c
> +++ b/contrib/elf2dmp/pdb.c
> @@ -19,6 +19,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/bswap.h"
>
> #include "pdb.h"
> #include "err.h"
> @@ -187,7 +188,7 @@ static int pdb_init_symbols(struct pdb_reader *r)
>
> r->symbols = symbols;
>
> - r->segments = *(uint16_t *)((const char *)symbols + sizeof(PDB_SYMBOLS) +
> + r->segments = lduw_le_p((const char *)symbols + sizeof(PDB_SYMBOLS) +
> symbols->module_size + symbols->offset_size +
> symbols->hash_size + symbols->srcmodule_size +
> symbols->pdbimport_size + symbols->unknown2_size +
This is a behaviour change -- previously we did a load in
host-endian order, but now we do it in little-endian order.
Which is correct?
If we need host-endian, then we have lduw_he_p() for that.
If we need little-endian, then maybe other parts of the code
also are loading data in the wrong endianness?
thanks
-- PMM
next prev parent reply other threads:[~2024-03-04 17:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 10:50 [PATCH 0/7] contrib/elf2dmp: Improve robustness Akihiko Odaki
2024-03-03 10:50 ` [PATCH 1/7] contrib/elf2dmp: Always check for PA resolution failure Akihiko Odaki
2024-03-04 17:47 ` Peter Maydell
2024-03-03 10:50 ` [PATCH 2/7] contrib/elf2dmp: Always destroy PA space Akihiko Odaki
2024-03-04 17:47 ` Peter Maydell
2024-03-03 10:50 ` [PATCH 3/7] contrib/elf2dmp: Ensure segment fits in file Akihiko Odaki
2024-03-04 17:52 ` Peter Maydell
2024-03-05 3:53 ` Akihiko Odaki
2024-03-03 10:50 ` [PATCH 4/7] contrib/elf2dmp: Use lduw_le_p() to read PDB Akihiko Odaki
2024-03-04 17:56 ` Peter Maydell [this message]
2024-03-03 10:50 ` [PATCH 5/7] contrib/elf2dmp: Use rol64() to decode Akihiko Odaki
2024-03-04 17:59 ` Peter Maydell
2024-03-03 10:50 ` [PATCH 6/7] contrib/elf2dmp: Continue even contexts are lacking Akihiko Odaki
2024-03-04 18:02 ` Peter Maydell
2024-03-03 10:50 ` [PATCH 7/7] MAINTAINERS: Add Akihiko Odaki as a elf2dmp reviewer Akihiko Odaki
2024-03-04 17:52 ` Peter Maydell
2024-03-04 18:03 ` [PATCH 0/7] contrib/elf2dmp: Improve robustness 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='CAFEAcA8TmKAPU_egO5tkHHFEodSJX_yssqx9kWaq=+tS1mrxnQ@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=qemu-devel@nongnu.org \
--cc=viktor.prutyanov@phystech.edu \
/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).