From nobody Mon Feb 9 16:02:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1637352712; cv=none; d=zohomail.com; s=zohoarc; b=i1KNG60bENft+Hou07XDjuh6EwnU0ZUDPasnKxOg0fAppLLMtTA6dqfXuh7La5djO+wkRscQXsppnKQWbA+IM5a/W8BHgR/7Kae4hv5syIyUIXMHvK+Qw67t6ue3YSnczp77WX+DvMOyhOPIjmFW4lOEUQayPZb5MWPwc8yac1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637352712; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tyeixmmwuZJID1W+S/tZDE99JTCY1osLTIUAw+RmmGY=; b=FKC9FBfBuXhpVFA2wPmfStbObPiJchbUWBckQo4MrgtieDCnLpaOw11BfL8GRRWkoeJHGEOIy8E/pKMmeU0NHV1yjOom4ftAxZUj3NzCmg3bW0wlDdOrXnBBkZvNp7iJ0Xr5KqBCswjDokBbimPAR4tzg6ttlyaS3l8tToa2Hn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1637352712406292.7635799441068; Fri, 19 Nov 2021 12:11:52 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-376-2nuZnR5nNGq5v0NDk_Y6ww-1; Fri, 19 Nov 2021 15:11:50 -0500 Received: by mail-wm1-f70.google.com with SMTP id v62-20020a1cac41000000b0033719a1a714so4540844wme.6 for ; Fri, 19 Nov 2021 12:11:50 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id q123sm13015208wma.30.2021.11.19.12.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 12:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637352711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tyeixmmwuZJID1W+S/tZDE99JTCY1osLTIUAw+RmmGY=; b=h1QADtltZ0rr91ZGnACrrVWwyBbuwqPOIpV4p1YbYa5ZCRyi7iByNZreb8av3IDXhabtGg DnTaGSRwleNsEO+7dpj4jrb77VygH/h/MyFY8j7eQWjTkcGKzpkECaYdSNkT17FRDILvLA i+cbO1WZh6CSS0vIXkacziq6mlDfLa4= X-MC-Unique: 2nuZnR5nNGq5v0NDk_Y6ww-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tyeixmmwuZJID1W+S/tZDE99JTCY1osLTIUAw+RmmGY=; b=AXtpAERvURVOzTd7Kt7dnGGUkOn4rdiJwhPnXrrN/9aW1QBMY+hI/KiDw4m83zJibS HuKFD/HPQU7IuScoHmcG3dcAz0RvSM2PH534xAx+EhX/3wVJtZ6YC3uLmygmKwv1Ig4B E09S5k1ADWuvnwJpvGLNNYMDg7nt3ZAjc625cRvOwZgD4CeDIEPjgoJK9fhcLHIur06z EIJ+S6vBSR59CFgTdWPaFo+Hu4no2yQtFTGeiOqA0vwHbkyRyc4JspzspBn8M067gtUB ArqzCyJyGaQqJwR7NYVDayRXqsuz/KWwyjMou/KIvbsNSN6AoGHo6TIP/kCx+X0jmj8G TWcw== X-Gm-Message-State: AOAM531mQUzQwXRj0eMwCcN7p+blh1eqkVAz4JQJqP7DxX58iFaFxKhf cuAR2qkdAEhsQsZLPDLxeMA06gAhpmtK89EP2X4sh+nTraOO4/iKsi/NlDRXe2i9k9wmUSnXl59 TqIACnYgp/Vd/dw== X-Received: by 2002:a5d:4b0e:: with SMTP id v14mr11064779wrq.196.1637352708762; Fri, 19 Nov 2021 12:11:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsfp2lkYJx1+otbjpU1L0/VpexWA/+XdcMu8ge67WwaaPeyZ6588vnjTZIon+MaE9MFF4cYw== X-Received: by 2002:a5d:4b0e:: with SMTP id v14mr11064745wrq.196.1637352708576; Fri, 19 Nov 2021 12:11:48 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bandan Das , Thomas Huth , Darren Kenny , Fam Zheng , Alexander Bulekov , Paolo Bonzini , Laurent Vivier , Stefan Hajnoczi , Qiuhao Li , qemu-block@nongnu.org, Hannes Reinecke , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-6.2 1/2] hw/scsi/megasas: Fails command if SGL buffer overflows Date: Fri, 19 Nov 2021 21:11:40 +0100 Message-Id: <20211119201141.532377-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211119201141.532377-1-philmd@redhat.com> References: <20211119201141.532377-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637352714167100001 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=C3=A9 --- No, I haven't looked at the datasheet. --- hw/scsi/megasas.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 4ff51221d4c..8f357841004 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); } --=20 2.31.1