patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommufd: Reject non-zero data_type if no data_len is provided
@ 2024-02-20 18:43 Jason Gunthorpe
  2024-02-21  7:11 ` Tian, Kevin
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2024-02-20 18:43 UTC (permalink / raw)
  To: iommu; +Cc: Kevin Tian, Nicolin Chen, patches, Yi Liu

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: bd529dbb661d ("iommufd: Add a nested HW pagetable object")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/iommufd/hw_pagetable.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
index 3f3f1fa1a0a946..33d142f8057d70 100644
--- a/drivers/iommu/iommufd/hw_pagetable.c
+++ b/drivers/iommu/iommufd/hw_pagetable.c
@@ -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
-- 
2.43.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-21 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 18:43 [PATCH] iommufd: Reject non-zero data_type if no data_len is provided Jason Gunthorpe
2024-02-21  7:11 ` Tian, Kevin
2024-02-21 13:33   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).