From nobody Tue Feb 10 12:09:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1618267285; cv=none; d=zohomail.com; s=zohoarc; b=V6g2lXicIvomvHiEESH61KPn9i1tNOihpHEQ571AXGD2x/gLqiCtQ8qLKTfpyh5A4oMcpqQIMcnWYBfGYU5FaFKKqRp+Rb2MY6EC5CbFAtkViRuvy3P9gwmGRoMere4KrW1TRupqXCArcEw1FLTi4g63D5VoDvmUBYJR+rlH2lQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618267285; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ufOtUndqeaULyD18wQwSoqB8tMNvubJoWSN9P6LxPOM=; b=VYv1VMZNWjXQgYad/N0xcIGL+GSY9Sc/jvWWkk5W/Wbx5yk3MN/KgVVbKtLAe3fCNENS8atXoaT4JY3000hiKqxakGcVboqRDDZHx+duDAdugC5ZMz1Ikuv7Xzx1/2sX+Jp8D9L2KdlRI6ejdE0bwdLfNTfjkG9294qt79llvMk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618267285708196.0827300045902; Mon, 12 Apr 2021 15:41:25 -0700 (PDT) Received: from localhost ([::1]:42500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW5FE-0007Gz-HU for importer@patchew.org; Mon, 12 Apr 2021 18:41:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW4wW-0003IZ-By for qemu-devel@nongnu.org; Mon, 12 Apr 2021 18:22:04 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:44112 helo=mail.default.ilande.uk0.bigv.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW4wU-0003CM-2m for qemu-devel@nongnu.org; Mon, 12 Apr 2021 18:22:04 -0400 Received: from host86-148-103-9.range86-148.btcentralplus.com ([86.148.103.9] helo=kentang.home) by mail.default.ilande.uk0.bigv.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lW4we-0004Dc-VW; Mon, 12 Apr 2021 23:22:17 +0100 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 12 Apr 2021 23:20:47 +0100 Message-Id: <20210412222048.22818-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210412222048.22818-1-mark.cave-ayland@ilande.co.uk> References: <20210412222048.22818-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 86.148.103.9 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 12/13] esp: ensure that do_cmd is set to zero before submitting an ESP select command X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.uk0.bigv.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.uk0.bigv.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" When a CDB has been received and is about to be submitted to the SCSI layer via one of the ESP select commands, ensure that do_cmd is set to zero before executing the command. Otherwise a guest executing 2 valid CDBs in quick sequence can invoke the S= CSI .transfer_data callback again before do_cmd is set to zero by the callback function triggering an assert at the start of esp_transfer_data(). Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210407195801.685-12-mark.cave-ayland@ilande.co.uk> --- hw/scsi/esp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 0037197bdb..b668acef82 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -357,6 +357,7 @@ static void handle_satn(ESPState *s) cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 1; + s->do_cmd =3D 0; do_cmd(s); } else if (cmdlen =3D=3D 0) { s->do_cmd =3D 1; @@ -390,6 +391,7 @@ static void handle_s_without_atn(ESPState *s) cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 0; + s->do_cmd =3D 0; do_busid_cmd(s, 0); } else if (cmdlen =3D=3D 0) { s->do_cmd =3D 1; --=20 2.20.1