Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1626858ybh; Thu, 16 Jul 2020 18:23:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAf0K324oX2E2MCRjTONk5GIVGE5yySMNU8ApRj8VCMnKg2z/qlMltv1B5PFjLDYOlU0oA X-Received: by 2002:a50:9dc8:: with SMTP id l8mr6959740edk.248.1594949016485; Thu, 16 Jul 2020 18:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594949016; cv=none; d=google.com; s=arc-20160816; b=vSsJYRRdbO4Z1IWVDikDZHsrfVvXPkdZLpwz6t/lMTeYjo8J7/6lm4HbQvIwfZS+tT 8fNiikOB4pkfnrbWoEC/zwGDA6dQnd+Ov6bcB/z6GOz4ul8yIJNfo7fAbUSz+mhyUhA1 GSkIAk1xFExTt/d7HrVMPysL2KXPe+uqGsHez5/AlGqKZ2Dear9ZiQnww+5v3FHjsEUn eoQLl3a9AiL5vzLhiGM+zJnwczqpVk2dGDyZhZuVC3LraozEPdAqflTr+v8TdpIMI48i zTYDDSc0uyiF3iAfM8jZyG9ME8J/IL0X63E6CicJPifg46L1npljcrCtV8d0eZ3z5zdG Tphw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:ironport-sdr:ironport-sdr; bh=ofg3cavl4xT+O2AGJNwm+WLF5oD68ZK84vxjrI9kO30=; b=fd6mrnL1+FY90mBzURJ0QN4ZWEMg+jE0XGD00b0K774cYnjXcEWad4kDdc1JnxYlZG mWe2+flZeEUu/7mzaU5fMz7dRuAb35pV5NCtBUOMa+6oIceJuiugtdUVXgfLf+96LLyb Yi0fnsQLJroq7FTNChkoBK37z2V19G88w3oNQTx+lN4j9WQqlA4ZFqe8oTCAQ44kUq4g 9dtSFyMce9e8v/YfGWqlT4ODJh5ys8ULZsCrdIS2tcWV00Nwwho+qMbfDob2tvPYaFXB f9weVOi6uuZDqThU7MIRU2YigrCtAeTcOFRhUeKpLLYTctsKcEYW0lVMHInbbEanNhLQ h+1A== 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 z8si4008819ejd.290.2020.07.16.18.23.13; Thu, 16 Jul 2020 18:23:36 -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 S1726870AbgGQBUL (ORCPT + 99 others); Thu, 16 Jul 2020 21:20:11 -0400 Received: from mga18.intel.com ([134.134.136.126]:48121 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbgGQBUK (ORCPT ); Thu, 16 Jul 2020 21:20:10 -0400 IronPort-SDR: cwYvtUxT2QoE8tW8DkEZkI4VQNXRrylE+K7fN8ZSDrrIVxxvm20n+fhvZZvXMIrtYSmjl/7xNx O5YftnQ1kC1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="136980128" X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="136980128" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 18:20:10 -0700 IronPort-SDR: DYKAK33VRoLIioAqsUIF1mjJoZdZfFn9W+1ZGu5cn72wUx+lyz2k2iLsFdLUdhSQA0oXfV5CXp 2G/8hxQxyBVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="460677441" Received: from allen-box.sh.intel.com (HELO [10.239.159.139]) ([10.239.159.139]) by orsmga005.jf.intel.com with ESMTP; 16 Jul 2020 18:20:06 -0700 Cc: baolu.lu@linux.intel.com, David Woodhouse , Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Jean-Philippe Brucker , Eric Auger , Jonathan Corbet Subject: Re: [PATCH v5 5/5] iommu/vt-d: Check UAPI data processed by IOMMU core To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson References: <1594925117-64892-1-git-send-email-jacob.jun.pan@linux.intel.com> <1594925117-64892-6-git-send-email-jacob.jun.pan@linux.intel.com> From: Lu Baolu Message-ID: Date: Fri, 17 Jul 2020 09:15:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1594925117-64892-6-git-send-email-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/17/20 2:45 AM, Jacob Pan wrote: > 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 Reviewed-by: Lu Baolu Best regards, baolu > --- > 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 f3a6ca88cf95..5e80484f0537 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -5383,8 +5383,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)) >