Commit 6278eecb authored by Jacob Pan's avatar Jacob Pan Committed by Joerg Roedel

iommu/vt-d: Check UAPI data processed by IOMMU core

IOMMU generic layer already does sanity checks on UAPI data for version
match and argsz range based on generic information.

This patch adjusts the following data checking responsibilities:
- removes the redundant version check from VT-d driver
- removes the check for vendor specific data size
- adds check for the use of reserved/undefined flags
Signed-off-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/1601051567-54787-7-git-send-email-jacob.jun.pan@linux.intel.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent d9057381
...@@ -5398,8 +5398,7 @@ intel_iommu_sva_invalidate(struct iommu_domain *domain, struct device *dev, ...@@ -5398,8 +5398,7 @@ intel_iommu_sva_invalidate(struct iommu_domain *domain, struct device *dev,
int ret = 0; int ret = 0;
u64 size = 0; u64 size = 0;
if (!inv_info || !dmar_domain || if (!inv_info || !dmar_domain)
inv_info->version != IOMMU_CACHE_INVALIDATE_INFO_VERSION_1)
return -EINVAL; return -EINVAL;
if (!dev || !dev_is_pci(dev)) if (!dev || !dev_is_pci(dev))
......
...@@ -284,8 +284,15 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev, ...@@ -284,8 +284,15 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
if (WARN_ON(!iommu) || !data) if (WARN_ON(!iommu) || !data)
return -EINVAL; return -EINVAL;
if (data->version != IOMMU_GPASID_BIND_VERSION_1 || if (data->format != IOMMU_PASID_FORMAT_INTEL_VTD)
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;
/* Make sure no undefined flags are used in vendor data */
if (data->vendor.vtd.flags & ~(IOMMU_SVA_VTD_GPASID_LAST - 1))
return -EINVAL; return -EINVAL;
if (!dev_is_pci(dev)) if (!dev_is_pci(dev))
......
...@@ -288,6 +288,7 @@ struct iommu_gpasid_bind_data_vtd { ...@@ -288,6 +288,7 @@ struct iommu_gpasid_bind_data_vtd {
#define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */ #define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */
#define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */ #define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */
#define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */ #define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */
#define IOMMU_SVA_VTD_GPASID_LAST (1 << 6)
__u64 flags; __u64 flags;
__u32 pat; __u32 pat;
__u32 emt; __u32 emt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment