From: Richard Henderson <richard.henderson@linaro.org>
To: Daniel Hoffman <dhoff749@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Alexey Kardashevskiy <aik@ozlabs.ru>,
David Gibson <david@gibson.dropbear.id.au>,
"open list:Virtual Open Firm..." <qemu-ppc@nongnu.org>
Subject: Re: [PATCH] ppc/spapr: Fix ubsan warning with unaligned pointer access
Date: Tue, 19 Dec 2023 17:45:53 -0800 [thread overview]
Message-ID: <1c5f886a-821e-46ff-bcea-045b07ebf809@linaro.org> (raw)
In-Reply-To: <20231217001441.146344-1-dhoff749@gmail.com>
On 12/16/23 16:14, Daniel Hoffman wrote:
> Found while running QTest with UBsan. Unaligned pointers appear to be
> valid, so moving the read to an explicit memcpy to an intermediate.
> ---
> hw/ppc/vof.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
> index e3b430a81f4..609a51c645d 100644
> --- a/hw/ppc/vof.c
> +++ b/hw/ppc/vof.c
> @@ -646,7 +646,10 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
> mem0_reg = fdt_getprop(fdt, offset, "reg", &proplen);
> g_assert(mem0_reg && proplen == sizeof(uint32_t) * (ac + sc));
> if (sc == 2) {
> - mem0_end = be64_to_cpu(*(uint64_t *)(mem0_reg + sizeof(uint32_t) * ac));
> + /* Pointer may be unaligned */
> + uint64_t mem0_end_copy;
> + memcpy(&mem0_end_copy, mem0_reg + sizeof(uint32_t) * ac, sizeof(mem0_end_copy));
> + mem0_end = be64_to_cpu(mem0_end_copy);
mem0_end = ldq_be_p(mem0_reg + sizeof(uint32_t) * ac);
r~
next prev parent reply other threads:[~2023-12-20 1:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-17 0:14 [PATCH] ppc/spapr: Fix ubsan warning with unaligned pointer access Daniel Hoffman
2023-12-20 1:45 ` Richard Henderson [this message]
2023-12-22 3:47 ` Alexey Kardashevskiy
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=1c5f886a-821e-46ff-bcea-045b07ebf809@linaro.org \
--to=richard.henderson@linaro.org \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=dhoff749@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-trivial@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).