Skip to content

Commit 7adc0c1

Browse files
committed
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. Fixes: bd529db ("iommufd: Add a nested HW pagetable object") Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 4bbcbc6 commit 7adc0c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iommu/iommufd/hw_pagetable.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
263263

264264
if (cmd->__reserved)
265265
return -EOPNOTSUPP;
266-
if (cmd->data_type == IOMMU_HWPT_DATA_NONE && cmd->data_len)
266+
if ((cmd->data_type == IOMMU_HWPT_DATA_NONE && cmd->data_len) ||
267+
(cmd->data_type != IOMMU_HWPT_DATA_NONE && !cmd->data_len))
267268
return -EINVAL;
268269

269270
idev = iommufd_get_device(ucmd, cmd->dev_id);

0 commit comments

Comments
 (0)