Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1137165pxk; Mon, 31 Aug 2020 10:46:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCQ7tZ6ElM8bN3KceGGtHWhLVesaT8pG0ZDrvESPHFktcLfhhmsiBSdSNousLT32NKrwpw X-Received: by 2002:a05:6402:54b:: with SMTP id i11mr2108610edx.326.1598895988263; Mon, 31 Aug 2020 10:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598895988; cv=none; d=google.com; s=arc-20160816; b=J9g4VoawS/0v72SrJ0x5qcj+5/4dswU1mVZKY2PKhFFUhduz/PAiXxpCFMqcK9lhdf vt3M27O54P4qUZULhAwN91FQt/D7ddCv5RYadTXv2cX9o+APVzHy47AbyE1E8IIGplNh Cp4JN8E4Lf5SqhJSwXEVf5aoYrJr8bLdg2c7VKgwSm84n8jKXKldiknzJ3cFqG743tr3 AlL1ji/zGoUMEpy//e3VEsYjSWCcebQKv6S7cMAp26YznuxMADEp7vi7AdCGa+VP/9qo tdPxHdDL0/c15Ktgo6suDPPKoE8ZQh9P2Y8YU4vnJ/QIeE9Uh/oynCBXrUzgJa6T4xg8 FAwg== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=MSONPREyUSInwLtwVmsYKXSuNNQ4RoA8AidJx5a5LY4=; b=lelbhBexr0gDEI7e0V2b19odQca8kf7nuNVwEl0dkGzkb8MVkIIMr+knk1BZjw6SkB 2jaUJ/m5X9rXTTjk6CK1/rQXULUFJTjUZHkv9HGFj+7MvUaLFdv6ZUnKLUQkg9kGpju8 QIB1gYk7qwARWnlu7TA+cTbfcXVlaiULTqSZoyIRJefUd54W4P4yLb3v8u0AwV//5zNb rSAZw3sJV9QZWDuBjqqBzyEeS3LwmU/V0js2n4M0t1iSnWLEt+BJAuQa2+ALyVQt9pzF cSLc/fyYWilcZk1QnZBDHJkGgNFm8dsW5oWqgYX2tPKq1j6HA3UDtarWXDfmq5wvgyTo VkQQ== 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 gz19si5687380ejb.176.2020.08.31.10.46.05; Mon, 31 Aug 2020 10:46:28 -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 S1727825AbgHaRpT (ORCPT + 99 others); Mon, 31 Aug 2020 13:45:19 -0400 Received: from mga01.intel.com ([192.55.52.88]:37338 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbgHaRpT (ORCPT ); Mon, 31 Aug 2020 13:45:19 -0400 IronPort-SDR: 4+pOY6XgtJz5GIYqWemHHJG51ckVZTx8t55r7HcHahSnMeJlCPUMSgSnB8p0BbqbCr4XCcpe22 ytNZ8pEMs2BA== X-IronPort-AV: E=McAfee;i="6000,8403,9730"; a="175075718" X-IronPort-AV: E=Sophos;i="5.76,376,1592895600"; d="scan'208";a="175075718" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 10:45:18 -0700 IronPort-SDR: 4V0HKjPMEFKjJ0dIOMZTyD7eACTRqRvtsa0jzkyZrLLFrCUNsnqyHPIMd+XP7P1heylDfFA6Ly bRfswT/CRLSw== X-IronPort-AV: E=Sophos;i="5.76,376,1592895600"; d="scan'208";a="340728810" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 10:45:17 -0700 Date: Mon, 31 Aug 2020 10:52:24 -0700 From: Jacob Pan To: Auger Eric Cc: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson , Lu Baolu , David Woodhouse , Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Jean-Philippe Brucker , Jonathan Corbet , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v7 7/7] iommu/vt-d: Check UAPI data processed by IOMMU core Message-ID: <20200831105224.7a90ba34@jacob-builder> In-Reply-To: <1b131401-a9a3-3641-99cc-430d9b51efa5@redhat.com> References: <1596068467-49322-1-git-send-email-jacob.jun.pan@linux.intel.com> <1596068467-49322-8-git-send-email-jacob.jun.pan@linux.intel.com> <1b131401-a9a3-3641-99cc-430d9b51efa5@redhat.com> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Aug 2020 11:19:46 +0200 Auger Eric wrote: > Hi Jacob, > > On 7/30/20 2:21 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 > > > --- > > 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; > Shouldn't you test the vendor flags here? > intel_pasid_setup_bind_data() only checks valid ones but not ~mask. > Yes, vendor flags should be tested to make sure there is no undefined flags being used. Thanks! > Thanks > > Eric > > > > if (!dev_is_pci(dev)) > > > [Jacob Pan]