iommu/uapi: Handle data and argsz filled by users
authorJacob Pan <jacob.pan.linux@gmail.com>
Fri, 25 Sep 2020 16:32:46 +0000 (09:32 -0700)
committerJoerg Roedel <jroedel@suse.de>
Thu, 1 Oct 2020 12:52:46 +0000 (14:52 +0200)
commitd90573812eea63c6bc8ab8a38f661b4c27c3cdc0
treefdfa6af56469682974fee6617d55c047dc599a66
parent23cc3493b5e107b8deb697cf3157a07276b5eff7
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

Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/1601051567-54787-6-git-send-email-jacob.jun.pan@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c
include/linux/iommu.h
include/uapi/linux/iommu.h