Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp195362pjb; Thu, 16 Jul 2020 11:41:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh9EhoVq2hwu6WiSB+QvZI7kqme9YBbIoX8P47V17b3DKNoSDrG6n4XNko4W/urPD7pkA/ X-Received: by 2002:a17:906:a0c8:: with SMTP id bh8mr5343319ejb.190.1594924877849; Thu, 16 Jul 2020 11:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594924877; cv=none; d=google.com; s=arc-20160816; b=wime2N6N4vtKJUyR3L/kETHLYMO2CWc5x0+w+4G6CiVGdzk4dfq1uOswY6y5c5Cz7h lMeDT62xHKZRestpJHBwZ9BxctOspnmri8zmQKBp4H5HNZhWIhMltldKGcmmBTarKbyk YTq3ozNLaY8fv9g6HEqXRQlBSNtre7wNsnvuyR/Jr4BhhmDxcux4vQYEWY/AczUZL8lg penvQKp/o6/lM04Q6smCPMNBHreS2svHpNBWQrPxjfjhuKuJWB+QvP3dZjiA7X/v8j0I K9hchsUEo+ewMOz3C45971voJfAWu9+qp3r+SxMRsyX/xU4yYNXk1eFYm+gYT5agHTNC bFUw== 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=hm1qRLgomHl1yTL/JavSDsDk2N3LmbGt/nmR9sc5EkA=; b=xWUq2StL7lAo1FgkueUk008E0sCQIZElsIYnvBCPpqfZcXNROkV1gVZzV9/YQg2jwW Z19Ch6MgyaxvKuN2KK7FrVHgjvYt3ICsd35dEIzr9enn4sQOYiXvdH3CBqcK2luFZBy4 QhgF9TEdaOLSr4NAfWUiebxDXWf5FLm8KhubUYQXbjACW9Ti14RsTbsKo11vqeHiT7RR oMEohrxaRS5xUTjzciXy58LN84lDQx4t20lFO8hg6314P1lht2++Y8o/tzI4jYEDqjsq NADzaaJXw1yNwyQIaUxy8J9MVsu87DWXuvTnikdaUzC4H2uo+/0ynucpfvBHtFsAk+1+ Uoyg== 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 l14si3783389edq.355.2020.07.16.11.40.54; Thu, 16 Jul 2020 11:41:17 -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 S1729497AbgGPSjC (ORCPT + 99 others); Thu, 16 Jul 2020 14:39:02 -0400 Received: from mga09.intel.com ([134.134.136.24]:21162 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728479AbgGPSip (ORCPT ); Thu, 16 Jul 2020 14:38:45 -0400 IronPort-SDR: gbt+GHd3r+PIqf7tp1xTr4h5Prdsu4AVxycO1i6Iyk5lsGLLEYk3GpiKi7fG9psvEaK7A83YRs IdPrHwMDqOUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="150857734" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="150857734" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 11:38:43 -0700 IronPort-SDR: LQKkNqx8qAF9JuLkKoio2GWHPoODxcKkMDnngzPnHHVvW4bDxKHuyvHoK7jEkP+THF7Ca4SiPS gq0n1WoqePMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="460572052" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 16 Jul 2020 11:38:35 -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 v5 5/5] iommu/vt-d: Check UAPI data processed by IOMMU core Date: Thu, 16 Jul 2020 11:45:17 -0700 Message-Id: <1594925117-64892-6-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594925117-64892-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1594925117-64892-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 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)) -- 2.7.4