Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma()
@ 2022-11-15 12:47 Dan Carpenter
  2022-11-15 13:22 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-11-15 12:47 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Kevin Tian, Joerg Roedel, Will Deacon, Robin Murphy, Nicolin Chen,
	iommu, kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iommu/iommufd/vfio_compat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/iommufd/vfio_compat.c b/drivers/iommu/iommufd/vfio_compat.c
index 976aa12b247d..30a13552d632 100644
--- a/drivers/iommu/iommufd/vfio_compat.c
+++ b/drivers/iommu/iommufd/vfio_compat.c
@@ -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;
-- 
2.35.1


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

* Re: [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma()
  2022-11-15 12:47 [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma() Dan Carpenter
@ 2022-11-15 13:22 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2022-11-15 13:22 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Kevin Tian, Joerg Roedel, Will Deacon, Robin Murphy, Nicolin Chen,
	iommu, kernel-janitors

On Tue, Nov 15, 2022 at 03:47:49PM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/iommu/iommufd/vfio_compat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iommu/iommufd/vfio_compat.c b/drivers/iommu/iommufd/vfio_compat.c
> index 976aa12b247d..30a13552d632 100644
> --- a/drivers/iommu/iommufd/vfio_compat.c
> +++ b/drivers/iommu/iommufd/vfio_compat.c
> @@ -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

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

end of thread, other threads:[~2022-11-15 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 12:47 [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma() Dan Carpenter
2022-11-15 13:22 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox