From nobody Mon Feb 9 05:10:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655952131; cv=none; d=zohomail.com; s=zohoarc; b=RzSRDxRGZs6Gk1l1o5ptSQ3fYrqfs+Vy8eoQupT6EGfZ6ebZQB52dfLjcRmNqE4KRv37vdboPBuaewyQuRCR03StqGOSBwO7LsRD5cBZWG0AszQ++MtUCI39GnXgDHfkihgPyDPbM1ecZqePmvXz9h3ZxXXVur6WMkrjgqdJ1Hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655952131; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=RceJ9WDBGgzMKy51pMzfVDCrpAsVF83fYN6/S1HfNhs=; b=TeGARwvkcbt7zgxrheap1zteHQbt7KS9JmR0kom3zVRVUrT9HDoA9v/AQUuyDOEGUNqrpLJlWLPtyfKjlQz0k3sVPzFQAEqUlleEWU1DwBm2ObM0tXyDqxfLLbTU5lp8kx2J0hApaLEHCheEJrZNhnGD5+UG98LhumOPzbpYYBQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655952131432962.1618828422884; Wed, 22 Jun 2022 19:42:11 -0700 (PDT) Received: from localhost ([::1]:35172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4CnJ-00024m-UB for importer@patchew.org; Wed, 22 Jun 2022 22:42:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4ClH-0001Gt-IC for qemu-devel@nongnu.org; Wed, 22 Jun 2022 22:40:03 -0400 Received: from mga05.intel.com ([192.55.52.43]:39338) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4ClD-0003Nv-8g for qemu-devel@nongnu.org; Wed, 22 Jun 2022 22:40:02 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 19:39:38 -0700 Received: from duan-server-s2600bt.bj.intel.com ([10.240.192.123]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 19:39:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655951999; x=1687487999; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fb3PgNrJbycZBknPv2N81nor5H78OvRGhnoQwAiIhdM=; b=WWoTt1DvYdnO5MAQx9bYcfrfNPT5fs1qAMdWaw+0+LRVs44U47KSRwbt tCKdDabqjU1xZqw4gNww5dTjC38Ld+e89LXClBbF2739mJParrFIQsWmG pg0k5JtULTIE2GqdVmdcGqNjNkNoNeyZX8pHWS0nENofBVA0tFa4VSRS3 TgZE7TR5n0td9JpnfgS81XSPW5NF1Ndzu7z0dOAkuWUMPDW82YWX9O0Hn CxNZ0OdABGS0Zp2Q5zeVyLa3KkVINy2vnyVM0uuBKhQC5+T23j3KdZG2q VCPCGBu0/+2U4xNBowZq2O/5pR/flIc/F1kETVjISCsxrOKSvxTPnHZOc Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="366925491" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="366925491" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="644504560" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: eric.auger@redhat.com, mst@redhat.com, jean-philippe@linaro.org Subject: [PATCH v3] virtio-iommu: Fix the partial copy of probe request Date: Thu, 23 Jun 2022 10:31:52 +0800 Message-Id: <20220623023152.3473231-1-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=192.55.52.43; envelope-from=zhenzhong.duan@intel.com; helo=mga05.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1655952133312100001 Content-Type: text/plain; charset="utf-8" The structure of probe request doesn't include the tail, this leads to a few field missed to be copied. Currently this isn't an issue as those missed field belong to reserved field, just in case reserved field will be used in the future. Changed 4th parameter of virtio_iommu_iov_to_req() to receive size of device-readable part. Fixes: 1733eebb9e75b ("virtio-iommu: Implement RESV_MEM probe request") Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger Reviewed-by: Jean-Philippe Brucker --- v3: moved "- sizeof(struct virtio_iommu_req_tail)" to virtio_iommu_handle_= req() per Jean v2: keep bugfix change and drop cleanup change hw/virtio/virtio-iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 7c122ab95780..08b227e828f8 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -675,11 +675,10 @@ static int virtio_iommu_probe(VirtIOIOMMU *s, =20 static int virtio_iommu_iov_to_req(struct iovec *iov, unsigned int iov_cnt, - void *req, size_t req_sz) + void *req, size_t payload_sz) { - size_t sz, payload_sz =3D req_sz - sizeof(struct virtio_iommu_req_tail= ); + size_t sz =3D iov_to_buf(iov, iov_cnt, 0, req, payload_sz); =20 - sz =3D iov_to_buf(iov, iov_cnt, 0, req, payload_sz); if (unlikely(sz !=3D payload_sz)) { return VIRTIO_IOMMU_S_INVAL; } @@ -692,7 +691,8 @@ static int virtio_iommu_handle_ ## __req(VirtIOIOMMU *s= , \ unsigned int iov_cnt) \ { \ struct virtio_iommu_req_ ## __req req; \ - int ret =3D virtio_iommu_iov_to_req(iov, iov_cnt, &req, sizeof(req)); \ + int ret =3D virtio_iommu_iov_to_req(iov, iov_cnt, &req, \ + sizeof(req) - sizeof(struct virtio_iommu_req_tail));\ \ return ret ? ret : virtio_iommu_ ## __req(s, &req); \ } --=20 2.25.1