From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Zheng Huang <hz1624917200@gmail.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Fam Zheng <fam@euphon.net>, Peter Xu <peterx@redhat.com>,
Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH] hw/scsi/esp: fix assertion error in fifo8_push
Date: Tue, 27 May 2025 15:59:23 +0200 [thread overview]
Message-ID: <684885a4-0022-4de8-98aa-07c9fe4a11c7@linaro.org> (raw)
In-Reply-To: <37889706-8576-476c-8fea-c1a3a2858b1e@gmail.com>
Hi,
Cc'ing maintainers:
$ ./scripts/get_maintainer.pl -f hw/scsi/esp.c
Paolo Bonzini <pbonzini@redhat.com> (supporter:SCSI)
Fam Zheng <fam@euphon.net> (reviewer:SCSI)
$ ./scripts/get_maintainer.pl -f migration/
Peter Xu <peterx@redhat.com> (maintainer:Migration)
Fabiano Rosas <farosas@suse.de> (maintainer:Migration)
On 27/5/25 15:12, Zheng Huang wrote:
> This patch add validation checks on FIFO structures in esp_post_load() to
> avoid assertion error `assert(fifo->num < fifo->capacity);` in fifo8_push(),
> which can occur if the inbound migration stream is malformed. By performing
> these checks during post-load, we can catch and handle such issues earlier,
> avoiding crashes due to corrupted state.
How can that happen? Can you share a reproducer?
>
> Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
> ---
> hw/scsi/esp.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index ac841dc32e..ba77017087 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -1350,11 +1350,17 @@ static int esp_post_load(void *opaque, int version_id)
> /* Migrate ti_buf to fifo */
> len = s->mig_ti_wptr - s->mig_ti_rptr;
> for (i = 0; i < len; i++) {
> + if (&s->fifo.num >= &s->fifo.capacity) {
> + return -1;
> + }
> fifo8_push(&s->fifo, s->mig_ti_buf[i]);
> }
>
> /* Migrate cmdbuf to cmdfifo */
> for (i = 0; i < s->mig_cmdlen; i++) {
> + if (&s->cmdfifo.num >= &s->cmdfifo.capacity) {
> + return -1;
> + }
> fifo8_push(&s->cmdfifo, s->mig_cmdbuf[i]);
> }
> }
next prev parent reply other threads:[~2025-05-27 14:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 13:12 [PATCH] hw/scsi/esp: fix assertion error in fifo8_push Zheng Huang
2025-05-27 13:59 ` Philippe Mathieu-Daudé [this message]
2025-05-27 19:40 ` Mark Cave-Ayland
2025-05-28 5:51 ` Zheng Huang
2025-05-28 13:07 ` Fabiano Rosas
2025-05-29 9:38 ` Zheng Huang
2025-05-28 5:54 ` Zheng Huang
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=684885a4-0022-4de8-98aa-07c9fe4a11c7@linaro.org \
--to=philmd@linaro.org \
--cc=fam@euphon.net \
--cc=farosas@suse.de \
--cc=hz1624917200@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--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).