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: <170752273224.1693615.11371097645648272257.stgit@bgt-140510-bm01.eng.stellus.in>
Date: Fri, 9 Feb 2024 23:52:12 +0000
From: Jim Harris <jim.harris@...sung.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>, "linux-pci@...r.kernel.org"
	<linux-pci@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, Leon Romanovsky <leonro@...dia.com>, "Jason
 Gunthorpe" <jgg@...dia.com>, Alex Williamson <alex.williamson@...hat.com>,
	"pierre.cregut@...nge.com" <pierre.cregut@...nge.com>
Subject: [PATCH v2 1/2] PCI/IOV: Revert
 "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes"

If an SR-IOV enabled device is held by vfio, and the device is removed,
vfio will hold device lock and notify userspace of the removal. If
userspace reads the sriov_numvfs sysfs entry, that thread will be blocked
since sriov_numvfs_show() also tries to acquire the device lock. If that
same thread is responsible for releasing the device to vfio, it results in
a deadlock.

The proper way to detect a change to the num_VFs value is to listen for a
sysfs event, not to add a device_lock() on the attribute _show() in the
kernel.

This reverts commit 35ff867b76576e32f34c698ccd11343f7d616204.
Revert had a small conflict, the sprintf() is now changed to sysfs_emit().

Link: https://lore.kernel.org/linux-pci/ZXJI5+f8bUelVXqu@ubuntu/
Suggested-by: Leon Romanovsky <leonro@...dia.com>
Reviewed-by: Leon Romanovsky <leonro@...dia.com>
Signed-off-by: Jim Harris <jim.harris@...sung.com>
---
 drivers/pci/iov.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index aaa33e8dc4c9..0ca20cd518d5 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -395,14 +395,8 @@ static ssize_t sriov_numvfs_show(struct device *dev,
 				 char *buf)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	u16 num_vfs;
-
-	/* Serialize vs sriov_numvfs_store() so readers see valid num_VFs */
-	device_lock(&pdev->dev);
-	num_vfs = pdev->sriov->num_VFs;
-	device_unlock(&pdev->dev);
 
-	return sysfs_emit(buf, "%u\n", num_vfs);
+	return sysfs_emit(buf, "%u\n", pdev->sriov->num_VFs);
 }
 
 /*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ