Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1530451ybg; Wed, 29 Jul 2020 17:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx12KFOKPQItaV1wOw7A1c92RbOt4Ro5oF5fkK3X3r4l3nACkJdFeQIRIcdYK+Wf4XeSxiC X-Received: by 2002:a05:6402:1d25:: with SMTP id dh5mr280332edb.266.1596068154548; Wed, 29 Jul 2020 17:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596068154; cv=none; d=google.com; s=arc-20160816; b=Ac5EpMr5yr3HTjuJpddwwnGFkolAptyLkgy49RTjpTvrt6o9W2qUrqCGKOYU1KcE/3 8ddrZEygKSIDA6NKjLivbwlmsgni9nG64XkUKQ61eEAVP5mJ+f03D7+3sHp7mheU2y4x +SbC6xzTwYXJrVjTXI9E62vVcfN0yOhk1XjoZ/5oaNTWQFCns9jBMo8CHEIGyezMhS0u DggtDRw3wKLdz4vT1DWZ+tNfJnsF34TD5s9IdEsndOuMF8N0O2/qcNpwCPKl09XN+HoW 4qE2LCTusDktiHYgDcFAcZ+IJbgig1EKxwj+a51qZmVhu6Ki5XhmiXhRolqhL9mVXNTB Upkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=+ysaiguNm+SGfr9/GtmgIhpZj8DvjtIdDk0MeExQn/8=; b=gc9trfvZeXqZM+8WoWrdinyF5jeYbQayzAQZGUw/0EJfGz9Ga8QSO74WRMub0J/OAV 4Tu3pnG8aLzWjcpoH9io7EYfFD510Gz7cNrOqvBtVpgashhVbkzGz/XtlycbdMAYA/3D jAvmujbxI+IlabLQ+JvXvD1aAGxfGi8x3CgOhpqWL8qWew7HVUU+yFgrw+WbaF9soqdd +U0CJLW0GTQDBSDKM5z4niiB9RKmeCZbSA6PUW44LAPqv/1/8dT7Fh7qjjeUMO1ZXPDS t+6T9soMd8IChjfvGYpGd4NoS4Gwaz9Wh3DvU3wY5djCVRKcIhkI54MWlzgCTkBJX4US 2mNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id um10si1238412ejb.119.2020.07.29.17.15.32; Wed, 29 Jul 2020 17:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbgG3AOh (ORCPT + 99 others); Wed, 29 Jul 2020 20:14:37 -0400 Received: from mga09.intel.com ([134.134.136.24]:33272 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728225AbgG3AOY (ORCPT ); Wed, 29 Jul 2020 20:14:24 -0400 IronPort-SDR: lEqg5LnYcX5iTzxui68tohMnh2MnhWQ3Gb89UkMzoJtYfz94Q9KB7xAO4iRggG+fCKkg2TkjXI EaLWdL2z4pfg== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="152748851" X-IronPort-AV: E=Sophos;i="5.75,412,1589266800"; d="scan'208";a="152748851" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 17:14:20 -0700 IronPort-SDR: 0ILJmDgohE/d9exFAy37m6A2IdOQjA+z1isX7wk15sn2vyRYV54jkNNKPkBxSC88ZZujMVw9ve 2t0Mo+/4oOJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,412,1589266800"; d="scan'208";a="286680262" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga003.jf.intel.com with ESMTP; 29 Jul 2020 17:14:19 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson Cc: "Lu Baolu" , David Woodhouse , Yi Liu , "Tian, Kevin" , Raj Ashok , "Christoph Hellwig" , Jean-Philippe Brucker , Eric Auger , Jonathan Corbet , Jacob Pan Subject: [PATCH v7 7/7] iommu/vt-d: Check UAPI data processed by IOMMU core Date: Wed, 29 Jul 2020 17:21:07 -0700 Message-Id: <1596068467-49322-8-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596068467-49322-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1596068467-49322-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IOMMU generic layer already does sanity checks UAPI data for version match and argsz range under generic information. Remove the redundant version check from VT-d driver and check for vendor specific data size. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 3 +-- drivers/iommu/intel/svm.c | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 021f62078f52..7e03cca31a0e 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -5391,8 +5391,7 @@ intel_iommu_sva_invalidate(struct iommu_domain *domain, struct device *dev, int ret = 0; u64 size = 0; - if (!inv_info || !dmar_domain || - inv_info->version != IOMMU_CACHE_INVALIDATE_INFO_VERSION_1) + if (!inv_info || !dmar_domain) return -EINVAL; if (!dev || !dev_is_pci(dev)) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 713b3a218483..55ea11e9c0f5 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -240,8 +240,11 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev, if (WARN_ON(!iommu) || !data) return -EINVAL; - if (data->version != IOMMU_GPASID_BIND_VERSION_1 || - data->format != IOMMU_PASID_FORMAT_INTEL_VTD) + if (data->format != IOMMU_PASID_FORMAT_INTEL_VTD) + return -EINVAL; + + /* IOMMU core ensures argsz is more than the start of the union */ + if (data->argsz < offsetofend(struct iommu_gpasid_bind_data, vendor.vtd)) return -EINVAL; if (!dev_is_pci(dev)) -- 2.7.4