iommufd: Reject non-zero data_type if no data_len is provided
Jason Gunthorpe
maintainerPATCH 1/1 iommufd: Reject non-zero data_type if no data_len is provided
Since the current design doesn't forward the data_type to the driver to check unless there is a data_len/uptr for a driver specific struct we should check and ensure that data_type is 0 if data_len is 0. Otherwise any value is permitted.
--- drivers/iommu/iommufd/hw_pagetable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/hw_pagetable.c +2 -1
@@ -263,7 +263,8 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)if (cmd->__reserved)return -EOPNOTSUPP ; -if (cmd->data_type ==IOMMU_HWPT_DATA_NONE && cmd->data_len) +if ((cmd->data_type ==IOMMU_HWPT_DATA_NONE && cmd->data_len) || + (cmd->data_type !=IOMMU_HWPT_DATA_NONE && !cmd->data_len))return -EINVAL ; idev =iommufd_get_device (ucmd, cmd->dev_id);
base-commit: 4bbcbc6ea2fa379632a24c14cfb47aa603816ac6
Signature · 1 line
2.43.2
Quoted 10 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 21, 2024 2:44 AMSince the current design doesn't forward the
data_typeto the driver to check unless there is a data_len/uptr for a driver specific struct we should check and ensure thatdata_typeis 0 ifdata_lenis 0. Otherwise any value is permitted.Fixes bd529dbb661d ("iommufd: Add a nested HW pagetable object")Signed-off-by Jason Gunthorpe <[email protected]>
Quoted 8 lines · Kevin
Quoted 8 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 21, 2024 2:44 AMSince the current design doesn't forward the
data_typeto the driver to check unless there is a data_len/uptr for a driver specific struct we should check and ensure thatdata_typeis 0 ifdata_lenis 0. Otherwise any value is permitted.
Quoted 4 lines
Quoted 2 lines
Fixes bd529dbb661d ("iommufd: Add a nested HW pagetable object")Signed-off-by Jason Gunthorpe <[email protected]>Reviewed-by Kevin Tian <[email protected]>
Applied to for-rc
Jason