New: Wrong Pci-Bridge Header Type check.
https://bugzilla.kernel.org/show_bug.cgi?id=43339
Summary: Wrong Pci-Bridge Header Type check.
Product: Virtualization
Version: unspecified
Kernel Version: 3.4
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: kvm
AssignedTo: [email protected]
ReportedBy: [email protected]
Regression: No
I have found bug in file virt/kvm/assigned-device.c
670 /* Don't allow bridges to be assigned */
671 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
672 if ((header_type & PCI_HEADER_TYPE) != PCI_HEADER_TYPE_NORMAL) {673 r = -EPERM;
674 goto out_put;
675 }
This code doesn't check that device is PCI-Bridge. In my case
header_type is 1, default value for PCI-BridgePCI_HEADER_TYPE is 14(0xE)PCI_HEADER_TYPE_NORMAL is 0
So, 1 & 0xE == 0 thus KVM assigns pci-bridge device to VM successfully.
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 43339] Wrong Pci-Bridge Header Type check.
https://bugzilla.kernel.org/show_bug.cgi?id=43339
Alex Williamson <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #1 from Alex Williamson <[email protected]> 2012-06-05 18:33:46 --- (In reply to comment #0)
Quoted 2 lines
So, 1 &
0xE== 0 thus KVM assigns pci-bridge device to VM successfully.
Have you found this to be true in practice? The test here is clearly wrong, but immediately after this we test pci-sysfs resource permissions. We only test standard device resources, as we're not expecting a bridge to get through, but I believe those should all be zero for a bridge, which will result in denying assignment of the device because it has no resources. If you have a pci-bridge that actually makes it through that test, please include lspci -vvv for it here. Thanks
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 43339] Wrong Pci-Bridge Header Type check.
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=43339
--- Comment #2 from Alex Williamson <[email protected]> 2012-06-05 19:43:18 --- Follow-up; I guess a bridge implementing BARs is not that unique. Many bridges do not have BARs, which should be rejected from assignment outright. Those with BARs will still fall into the requirement that the user will require permission to the pci-sysfs resource files, so a privileged entity still has to grant access to the device. Let me know if you find differently. Thanks
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 43339] Wrong Pci-Bridge Header Type check.
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=43339
Florian Mickler <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #3 from Florian Mickler <[email protected]> 2012-07-01 09:40:03 --- A patch referencing this bug report has been merged in Linux v3.5-rc4:
commit f961f72836eb6c0fd76201f6f6b2fafff93c4cea
Author: Jan Kiszka <[email protected]> Date: Fri Jun 15 07:56:20 2012 -0600
KVM: Fix PCI header check on device assignment
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 43339] Wrong Pci-Bridge Header Type check.
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=43339
Alan <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |[email protected]
Resolution| |CODE_FIXSignature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.