Linux IOMMU Development
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Kevin Tian <kevin.tian@intel.com>, Joerg Roedel <joro@8bytes.org>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Nicolin Chen <nicolinc@nvidia.com>,
	iommu@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma()
Date: Tue, 15 Nov 2022 15:47:49 +0300	[thread overview]
Message-ID: <Y3OKdW/WXVr1VYbc@kili> (raw)

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


             reply	other threads:[~2022-11-15 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 12:47 Dan Carpenter [this message]
2022-11-15 13:22 ` [PATCH] iommufd: vfio: info leak in iommufd_vfio_unmap_dma() Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3OKdW/WXVr1VYbc@kili \
    --to=error27@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox