]> git.ipfire.org Git - thirdparty/qemu.git/commit
esp: restrict non-DMA transfer length to that of available data
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Wed, 13 Sep 2023 20:44:09 +0000 (21:44 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 3 Oct 2023 15:25:00 +0000 (18:25 +0300)
commitfa2f090d6225b1266fa1a44f27e3048f530ef06e
tree05321f413ca47d2b04b83a5fa3f869af4b585b1f
parent9b7feb87d0acfda5aff5b0830740ddc2d9ed7dcb
esp: restrict non-DMA transfer length to that of available data

In the case where a SCSI layer transfer is incorrectly terminated, it is
possible for a TI command to cause a SCSI buffer overflow due to the
expected transfer data length being less than the available data in the
FIFO. When this occurs the unsigned async_len variable underflows and
becomes a large offset which writes past the end of the allocated SCSI
buffer.

Restrict the non-DMA transfer length to be the smallest of the expected
transfer length and the available FIFO data to ensure that it is no longer
possible for the SCSI buffer overflow to occur.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1810
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230913204410.65650-3-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 77668e4b9bca03a856c27ba899a2513ddf52bb52)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/scsi/esp.c