[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 02/15] pcie_sriov: Validate NumVFs
From: |
Akihiko Odaki |
Subject: |
[PATCH v8 02/15] pcie_sriov: Validate NumVFs |
Date: |
Wed, 28 Feb 2024 20:33:13 +0900 |
The guest may write NumVFs greater than TotalVFs and that can lead
to buffer overflow in VF implementations.
Cc: qemu-stable@nongnu.org
Fixes: CVE-2024-26327
Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization
(SR/IOV)")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
hw/pci/pcie_sriov.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index a1fe65f5d801..da209b7f47fd 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -176,6 +176,9 @@ static void register_vfs(PCIDevice *dev)
assert(sriov_cap > 0);
num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
+ if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_VF)) {
+ return;
+ }
dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
--
2.43.2
- [PATCH v8 00/15] hw/pci: SR-IOV related fixes and improvements, Akihiko Odaki, 2024/02/28
- [PATCH v8 01/15] hw/nvme: Use pcie_sriov_num_vfs(), Akihiko Odaki, 2024/02/28
- [PATCH v8 03/15] pcie_sriov: Reset SR-IOV extended capability, Akihiko Odaki, 2024/02/28
- [PATCH v8 02/15] pcie_sriov: Validate NumVFs,
Akihiko Odaki <=
- [PATCH v8 05/15] hw/pci: Always call pcie_sriov_pf_reset(), Akihiko Odaki, 2024/02/28
- [PATCH v8 04/15] pcie_sriov: Do not reset NumVFs after disabling VFs, Akihiko Odaki, 2024/02/28
- [PATCH v8 07/15] pcie_sriov: Do not manually unrealize, Akihiko Odaki, 2024/02/28
- [PATCH v8 06/15] hw/pci: Rename has_power to enabled, Akihiko Odaki, 2024/02/28
- [PATCH v8 08/15] pcie_sriov: Reuse SR-IOV VF device instances, Akihiko Odaki, 2024/02/28
- [PATCH v8 09/15] pcie_sriov: Release VFs failed to realize, Akihiko Odaki, 2024/02/28
- [PATCH v8 10/15] pcie_sriov: Remove num_vfs from PCIESriovPF, Akihiko Odaki, 2024/02/28
- [PATCH v8 11/15] pcie_sriov: Register VFs after migration, Akihiko Odaki, 2024/02/28