From 97a2b074d150918a7a3a4065b946a52d4d0be8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 19 Nov 2021 21:11:40 +0100 Subject: hw/scsi/megasas: Fails command if SGL buffer overflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we detect an overflow on the SGL buffer, do not keep processing the command: discard it. TARGET_FAILURE sense code will be returned (MFI_STAT_SCSI_DONE_WITH_ERROR). Reported-by: Alexander Bulekov Resolves: https://gitlab.com/qemu-project/qemu/-/issues/521 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Darren Kenny Message-Id: <20211119201141.532377-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/scsi') diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 4ff5122..8f35784 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -303,6 +303,7 @@ static int megasas_map_sgl(MegasasState *s, MegasasCmd *cmd, union mfi_sgl *sgl) } if (cmd->iov_size > iov_size) { trace_megasas_iovec_overflow(cmd->index, iov_size, cmd->iov_size); + goto unmap; } else if (cmd->iov_size < iov_size) { trace_megasas_iovec_underflow(cmd->index, iov_size, cmd->iov_size); } -- cgit v1.1