From: David Woodhouse <dwmw2@infradead.org>
To: Akihiko Odaki <akihiko.odaki@daynix.com>,
Paul Durrant <paul@xen.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>
Cc: qemu-devel@nongnu.org, devel@daynix.com
Subject: Re: [PATCH] hw/xen: Check if len is 0 before memcpy()
Date: Wed, 08 Jan 2025 11:47:25 +0000 [thread overview]
Message-ID: <6a067b445df6e5797e001665ab8554e4fc5085fe.camel@infradead.org> (raw)
In-Reply-To: <20250108-xen-v1-1-3f95cd358eed@daynix.com>
[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]
On Wed, 2025-01-08 at 20:31 +0900, Akihiko Odaki wrote:
> data->data can be NULL when len is 0. Strictly speaking, the behavior
> of memcpy() in such a scenario is undefined so UBSan complaints.
>
> Satisfy UBSan by checking if len is 0 before memcpy().
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Thanks.
> ---
> hw/i386/kvm/xen_xenstore.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c
> index 59691056670e..17802aa33d20 100644
> --- a/hw/i386/kvm/xen_xenstore.c
> +++ b/hw/i386/kvm/xen_xenstore.c
> @@ -532,6 +532,10 @@ static void xs_read(XenXenstoreState *s,
> unsigned int req_id,
> return;
> }
>
> + if (!len) {
> + return;
> + }
> +
> memcpy(&rsp_data[rsp->len], data->data, len);
> rsp->len += len;
> }
>
> ---
> base-commit: 38d0939b86e2eef6f6a622c6f1f7befda0146595
> change-id: 20241227-xen-fb5a15cc0ca7
>
> Best regards,
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
prev parent reply other threads:[~2025-01-08 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 11:31 [PATCH] hw/xen: Check if len is 0 before memcpy() Akihiko Odaki
2025-01-08 11:42 ` Philippe Mathieu-Daudé
2025-01-08 11:47 ` David Woodhouse [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=6a067b445df6e5797e001665ab8554e4fc5085fe.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=akihiko.odaki@daynix.com \
--cc=devel@daynix.com \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).