All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Yaxing Guo <guoyaxing@bosc.ac.cn>,
	linux-kernel@vger.kernel.org, Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] uio: uio_pci_generic_sva: reject multiple opens
Date: Wed, 28 Oct 2026 09:27:26 +0200	[thread overview]
Message-ID: <20261028072725.623111-2-thnkslprpt@gmail.com> (raw)

uio_pci_sva_open() stores an SVA binding handle in device-wide state.
A second open from another address space overwrites that handle. Closing
the two descriptors then unbinds the second handle twice and leaves the
first binding active.

Reject another open while a binding is active and clear the handle on
release. UIO core already serializes the callbacks under info_lock.

Fixes: 3397c3cd859a ("uio: Add SVA support for PCI devices via uio_pci_generic_sva.c")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 drivers/uio/uio_pci_generic_sva.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/uio/uio_pci_generic_sva.c b/drivers/uio/uio_pci_generic_sva.c
index d05ef77f7e322..fedf54e82f270 100644
--- a/drivers/uio/uio_pci_generic_sva.c
+++ b/drivers/uio/uio_pci_generic_sva.c
@@ -32,6 +32,9 @@ static int uio_pci_sva_open(struct uio_info *info, struct inode *inode)
 	if (!udev || !udev->pdev)
 		return -ENODEV;
 
+	if (udev->sva_handle)
+		return -EBUSY;
+
 	domain = iommu_get_domain_for_dev(&udev->pdev->dev);
 	if (domain)
 		iommu_detach_device(domain, &udev->pdev->dev);
@@ -55,6 +58,7 @@ static int uio_pci_sva_release(struct uio_info *info, struct inode *inode)
 		return -ENODEV;
 
 	iommu_sva_unbind_device(udev->sva_handle);
+	udev->sva_handle = NULL;
 
 	return 0;
 }

base-commit: 65ba8f34ec886ec72b2c07ddc8cf3d815c32869d
-- 
2.43.0


             reply	other threads:[~2026-10-28  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  7:27 Avi Weiss [this message]
2026-10-28  8:04 ` [PATCH] uio: uio_pci_generic_sva: reject multiple opens Greg Kroah-Hartman

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=20261028072725.623111-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guoyaxing@bosc.ac.cn \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.