From nobody Wed Apr 9 11:59:33 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.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; dmarc=pass(p=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1739447202; cv=none; d=zohomail.com; s=zohoarc; b=ZI/YGH0sHwVFu0XdvvH1ieoMebGP+cRHo6x+e5oYuf6t2wSlhJg6DjFMtumYTxOHI7Dg6asslDjOKBNsF/1gwZqmY1q2dAoRnR3cFAgD3eQhMS71rMXPpdqvgD7CGqgCMfXNhEscsmPpWmIVO5A3xE4nIy5aR540/fCGv8sZqzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739447202; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lL2Y6LqQ4b46Dr+kJFr/TmMrYftcnjDurs+LN2y3h8E=; b=I+Cf0ZGdzorW/FkMrq0f+oA+YvsvEe/ozHMizUs5whq9s0cVPs11/2HtBLx9I7yegj2XsvTVaYQ2O9h3+whCpiHcdDnX20lHPZOxzW+ziNpHig27efFsCpVO9AYmE2wL1Ll1vftWvXGnNWlWWhm9T9q4WYaWP7Ib81ZW8TYnd4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739447202752602.1511844325937; Thu, 13 Feb 2025 03:46:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tiXfN-0002y6-Lq; Thu, 13 Feb 2025 06:46:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tiXfG-0002xj-5V; Thu, 13 Feb 2025 06:45:56 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tiXfE-0005hB-DD; Thu, 13 Feb 2025 06:45:53 -0500 Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2025 11:45:46 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.38.20:65043] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.29.115:2525] with esmtp (Farcaster) id 10549cb2-9ec4-4781-8830-434f14aa7401; Thu, 13 Feb 2025 11:45:44 +0000 (UTC) Received: from EX19D020UWC004.ant.amazon.com (10.13.138.149) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.39; Thu, 13 Feb 2025 11:45:43 +0000 Received: from ip-10-253-83-51.amazon.com (10.253.83.51) by EX19D020UWC004.ant.amazon.com (10.13.138.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.39; Thu, 13 Feb 2025 11:45:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1739447152; x=1770983152; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lL2Y6LqQ4b46Dr+kJFr/TmMrYftcnjDurs+LN2y3h8E=; b=P+Nie4bos4SgnWZOAzyFzqnFhzAs+anJJ1khfMgsCjK++RdlJULG0xWW Edo65M1GAObBQDIyK76u3ftsRSAJKDPPtM35yO3ahzsVGa9m2Vk7ciFGr dTw+YzH+OUhm5iofJw0CCkTIv63pvcR9QzKmr6uWSykRdRLz4fbLsZVWI A=; X-IronPort-AV: E=Sophos;i="6.13,282,1732579200"; d="scan'208";a="471830947" X-Farcaster-Flow-ID: 10549cb2-9ec4-4781-8830-434f14aa7401 From: Alexander Graf To: CC: , Dorjoy Chowdhury , Vikrant Garg , Subject: [PATCH] hw/virtio/virtio-nsm: Respond with correct length Date: Thu, 13 Feb 2025 11:45:41 +0000 Message-ID: <20250213114541.67515-1-graf@amazon.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.253.83.51] X-ClientProxiedBy: EX19D042UWA002.ant.amazon.com (10.13.139.17) To EX19D020UWC004.ant.amazon.com (10.13.138.149) 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=52.95.49.90; envelope-from=prvs=1325cea77=graf@amazon.de; helo=smtp-fw-6002.amazon.com X-Spam_score_int: -57 X-Spam_score: -5.8 X-Spam_bar: ----- X-Spam_report: (-5.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1739447204243019100 Content-Type: text/plain; charset="utf-8" When we return a response packet from NSM, we need to indicate its length according to the content of the response. Prior to this patch, we returned the length of the source buffer, which may confuse guest code that relies on the response size. Fix it by returning the response payload size instead. Fixes: bb154e3e0cc715 ("device/virtio-nsm: Support for Nitro Secure Module = device") Reported-by: Vikrant Garg Signed-off-by: Alexander Graf Reviewed-by: Dorjoy Chowdhury Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Vikrant Garg --- hw/virtio/virtio-nsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c index 098e1aeac6..b22aa74e34 100644 --- a/hw/virtio/virtio-nsm.c +++ b/hw/virtio/virtio-nsm.c @@ -1596,7 +1596,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueu= e *vq) g_free(req.iov_base); g_free(res.iov_base); virtqueue_push(vq, out_elem, 0); - virtqueue_push(vq, in_elem, in_elem->in_sg->iov_len); + virtqueue_push(vq, in_elem, sz); virtio_notify(vdev, vq); return; =20 --=20 2.47.1