qemu/hw/pci
Akihiko Odaki cad9aa6fbd pcie_sriov: Fix configuration and state synchronization
Fix issues in PCIe SR-IOV configuration register handling that caused
inconsistent internal state due to improper write mask handling and
incorrect migration behavior.

Two main problems were identified:

1. VF Enable bit write mask handling:
   pcie_sriov_config_write() incorrectly assumed that its val parameter
   was already masked, causing it to ignore the actual write mask.
   This led to the VF Enable bit being processed even when masked,
   resulting in incorrect VF registration/unregistration. It is
   identified as CVE-2025-54567.

2. Migration state inconsistency:
   pcie_sriov_pf_post_load() unconditionally called register_vfs()
   regardless of the VF Enable bit state, creating inconsistent
   internal state when VFs should not be enabled. Additionally,
   it failed to properly update the NumVFs write mask based on
   the current configuration. It is identified as CVE-2025-54566.

Root cause analysis revealed that both functions relied on incorrect
special-case assumptions instead of properly reading and consuming
the actual configuration values. This change introduces a unified
consume_config() function that reads actual configuration values and
synchronize the internal state without special-case assumptions.

The solution only adds register read overhead in non-hot-path code
while ensuring correct SR-IOV state management across configuration
writes and migration scenarios.

Fixes: 5e7dd17e43 ("pcie_sriov: Remove num_vfs from PCIESriovPF")
Fixes: f9efcd4711 ("pcie_sriov: Register VFs after migration")
Fixes: CVE-2025-54566
Fixes: CVE-2025-54567
Cc: qemu-stable@nongnu.org
Reported-by: Corentin BAYET <corentin.bayet@reversetactics.com>
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Message-Id: <20250727-wmask-v2-1-394910b1c0b6@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2025-08-01 08:33:04 -04:00
..
Kconfig kconfig: Add PCIe devices to s390x machines 2023-07-14 11:10:57 +02:00
meson.build meson: remove CONFIG_ALL 2023-12-31 09:11:28 +01:00
msi.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
msix.c pci: export msix_is_pending 2025-06-11 14:01:58 +02:00
pci_bridge.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
pci_host.c hw/pci-host: Remove unused pci_host_data_be_ops 2025-05-20 08:04:18 +02:00
pci-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
pci-internal.h hw/pci/aer: Make PCIE AER error injection facility available for other emulation to use. 2023-03-07 12:39:00 -05:00
pci-qmp-cmds.c pci: Move QMP commands to new hw/pci/pci-qmp-cmds.c 2022-12-19 16:15:17 +01:00
pci-stub.c hw/pci: remove return after g_assert_not_reached() 2024-09-24 13:53:35 +02:00
pci.c pci: skip reset during cpr 2025-06-11 14:01:58 +02:00
pcie_aer.c hw/pci: Constify VMState 2023-12-30 07:38:06 +11:00
pcie_doe.c hw/pci: PCIe Data Object Exchange emulation 2022-11-07 13:12:19 -05:00
pcie_host.c include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
pcie_port.c hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo 2025-05-08 14:22:12 +02:00
pcie_sriov.c pcie_sriov: Fix configuration and state synchronization 2025-08-01 08:33:04 -04:00
pcie.c pcie: Helper functions to check to check if PRI is enabled 2025-06-01 06:38:53 -04:00
shpc.c hw/pci: add some convenient trace-events for pcie and shpc hotplug 2024-03-11 22:09:42 +01:00
slotid_cap.c include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
trace-events hw/pci/pci.c: Turn DPRINTF into trace events 2025-05-09 23:49:26 +03:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00