Skip to contentSkip to conversation

iommufd: vfio: info leak in iommufd_vfio_unmap_dma()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommufd: vfio: info leak in iommufd_vfio_unmap_dma()

If iopt_unmap_iova() fails then "unmapped" is uninitialized. Copying it to the user can leak stack information.

Fixes 32c328dc9b73 ("iommufd: vfio container FD ioctl compatibility")
---
 drivers/iommu/iommufd/vfio_compat.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/iommufd/vfio_compat.c +3 -0
index 976aa12b247d..30a13552d632 100644
@@ -189,6 +189,9 @@ static int iommufd_vfio_unmap_dma(struct iommufd_ctx *ictx, unsigned int cmd,
 		rc = iopt_unmap_iova(&ioas->iopt, unmap.iova, unmap.size,
 				     &unmapped);
 	}
+	if (rc)
+		goto err_put;
+
 	unmap.size = unmapped;
 	if (copy_to_user(arg, &unmap, minsz))
 		rc = -EFAULT;
Signature · 1 line
2.35.1
#1 lore raw
Quoted 14 lines · Dan Carpenter

If iopt_unmap_iova() fails then "unmapped" is uninitialized. Copying it to the user can leak stack information.

Fixes 32c328dc9b73 ("iommufd: vfio container FD ioctl compatibility")
---
 drivers/iommu/iommufd/vfio_compat.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/iommufd/vfio_compat.c +0 -0
index 976aa12b247d..30a13552d632 100644

drivers/iommu/iommufd/vfio_compat.c static int iommufd_vfio_unmap_dma(struct iommufd_ctx *ictx, unsigned int cmd, · line 194

Quoted 6 lines
drivers/iommu/iommufd/vfio_compat.c +3 -0
@@ -189,6 +189,9 @@ static int iommufd_vfio_unmap_dma(struct iommufd_ctx *ictx, unsigned int cmd,
 		rc = iopt_unmap_iova(&ioas->iopt, unmap.iova, unmap.size,
 				     &unmapped);
 	}
+	if (rc)
+		goto err_put;
+

It should be inited to 0, I fixed it, thanks

Jason