History

iommu/uapi: Handle data and argsz filled by users

IOMMU user APIs are responsible for processing user data. This patch changes the interface such that user pointers can be passed into IOMMU code directly. Separate kernel APIs without user pointers are introduced for in-kernel users of the UAPI functionality. IOMMU UAPI data has a user filled argsz field which indicates the data length of the structure. User data is not trusted, argsz must be validated based on the current kernel data size, mandatory data size, and feature flags. User data may also be extended, resulting in possible argsz increase. Backward compatibility is ensured based on size and flags (or the functional equivalent fields) checking. This patch adds sanity checks in the IOMMU layer. In addition to argsz, reserved/unused fields in padding, flags, and version are also checked. Details are documented in Documentation/userspace-api/iommu.rst

Jacob Pan committed 6 years ago

Commit d9057381 parent 23cc3493 files · +207 −16Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/iommu.h+1−0
@@ -322,6 +322,7 @@ struct iommu_gpasid_bind_data { · 321 unmodified lines
322#define IOMMU_GPASID_BIND_VERSION_1 1322#define IOMMU_GPASID_BIND_VERSION_1 1
323 __u32 version;323 __u32 version;
324#define IOMMU_PASID_FORMAT_INTEL_VTD 1324#define IOMMU_PASID_FORMAT_INTEL_VTD 1
325#define IOMMU_PASID_FORMAT_LAST 2
325 __u32 format;326 __u32 format;
326 __u32 addr_width;327 __u32 addr_width;
327#define IOMMU_SVA_GPASID_VAL (1 << 0) /* guest PASID valid */328#define IOMMU_SVA_GPASID_VAL (1 << 0) /* guest PASID valid */