lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1551617881-8520-3-git-send-email-yi.l.liu@intel.com>
Date:   Sun,  3 Mar 2019 20:58:01 +0800
From:   "Liu, Yi L" <yi.l.liu@...el.com>
To:     alex.williamson@...hat.com, kwankhede@...dia.com
Cc:     kevin.tian@...el.com, baolu.lu@...ux.intel.com, joro@...tes.org,
        jean-philippe.brucker@....com, peterx@...hat.com,
        linux-kernel@...r.kernel.org, yi.l.liu@...el.com,
        yi.y.sun@...el.com, Liu@...r.kernel.org
Subject: [RFC v1 2/2] vfio/pci: expose only mdev interface if in pci-mdev mode

If a pci device is wrapped as a mediated device. Then user should
only passthru it via vfio mdev framework. If not, there would be
conflict during the device access. This patch prevents user from
using legacy vfio-pci passthru interface. vfio-pci driver will only
expose mdev interface when working in pci-mdev mode. Thus could
prevent user from passthru device in legacy manner.

Cc: Kevin Tian <kevin.tian@...el.com>
Cc: Lu Baolu <baolu.lu@...ux.intel.com>
Signed-off-by: Liu, Yi L <yi.l.liu@...el.com>
---
 drivers/vfio/pci/vfio_pci.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index d1c3fe6..422a3ff 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1273,11 +1273,15 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	mutex_init(&vdev->ioeventfds_lock);
 	INIT_LIST_HEAD(&vdev->ioeventfds_list);
 
-	ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev);
-	if (ret) {
-		vfio_iommu_group_put(group, &pdev->dev);
-		kfree(vdev);
-		return ret;
+	if (vfio_pci_mdev_mode) {
+		pci_set_drvdata(pdev, vdev);
+	} else {
+		ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev);
+		if (ret) {
+			vfio_iommu_group_put(group, &pdev->dev);
+			kfree(vdev);
+			return ret;
+		}
 	}
 
 	ret = vfio_pci_reflck_attach(vdev);
@@ -1329,7 +1333,10 @@ static void vfio_pci_remove(struct pci_dev *pdev)
 {
 	struct vfio_pci_device *vdev;
 
-	vdev = vfio_del_group_dev(&pdev->dev);
+	if (vfio_pci_mdev_mode)
+		vdev = pci_get_drvdata(pdev);
+	else
+		vdev = vfio_del_group_dev(&pdev->dev);
 	if (!vdev)
 		return;
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ