CVE-2025-40219
JSON

Not scored

PCI/IOV: Fix race between SR-IOV enable/disable and hotplug

Severity
Not scored
Exploit likelihood
0.25% (higher than 17% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") tried to fix a race between the VF removal inside sriov_del_vfs() and concurrent hot unplug by taking the PCI rescan/remove lock in sriov_del_vfs(). Similarly the PCI rescan/remove lock was also taken in sriov_add_vfs() to protect addition of VFs. This approach however causes deadlock on trying to remove PFs with SR-IOV enabled because PFs disable SR-IOV during removal and this removal happens under the PCI rescan/remove lock. So the original fix had to be reverted. Instead of taking the PCI rescan/remove lock in sriov_add_vfs() and sriov_del_vfs(), fix the race that occurs with SR-IOV enable and disable vs hotplug higher up in the callchain by taking the lock in sriov_numvfs_store() before calling into the driver's sriov_configure() callback.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 18f9e9d150fccfa747875df6f0a9f606740762b3 before 3cddde484471c602bea04e6f384819d336a1ff84, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before d7673ac466eca37ec3e6b7cc9ccdb06de3304e9b, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before 7c37920c96b85ef4255a7acc795e99e63dd38d59, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before 1047ca2d816994f31e1475e63e0c0b7825599747, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before 97c18f074ff1c12d016a0753072a3afdfa0b9611, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before bea1d373098b22d7142da48750ce5526096425bc, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before f3015627b6e9ddf85cfeaf42405b3c194dde2c36, from 18f9e9d150fccfa747875df6f0a9f606740762b3 before a5338e365c4559d7b4d7356116b0eb95b12e08d5 and 1 more
Not affected: before 5.0, from 5.10.252 up to 5.10.*, from 5.15.202 up to 5.15.*, from 6.1.165 up to 6.1.*, from 6.6.128 up to 6.6.*, from 6.12.75 up to 6.12.*
CVE List

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") tried to fix a race between the VF removal inside sriov_del_vfs() and concurrent hot unplug by taking the PCI rescan/remove lock in sriov_del_vfs(). Similarly the PCI rescan/remove lock was also taken in sriov_add_vfs() to protect addition of VFs. This approach however causes deadlock on trying to remove PFs with SR-IOV enabled because PFs disable SR-IOV during removal and this removal happens under the PCI rescan/remove lock. So the original fix had to be reverted. Instead of taking the PCI rescan/remove lock in sriov_add_vfs() and sriov_del_vfs(), fix the race that occurs with SR-IOV enable and disable vs hotplug higher up in the callchain by taking the lock in sriov_numvfs_store() before calling into the driver's sriov_configure() callback.

NVD (es)

En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta: PCI/IOV: Añadir bloqueo de reescaneo-eliminación de PCI al habilitar/deshabilitar SR-IOV Antes de deshabilitar SR-IOV a través de accesos al espacio de configuración del PF padre, 'sriov_disable()' primero elimina los dispositivos PCI que representan las VF. Desde el commit 9d16947b7583 (“PCI: Añadir bloqueo global pci_lock_rescan_remove()”), dichas operaciones de eliminación se serializan frente a eliminaciones y reescaneos concurrentes utilizando el 'pci_rescan_remove_lock'. Sin embargo, nunca se añadió tal bloqueo en 'sriov_disable()'. En particular, cuando el commit 18f9e9d150fc (“PCI/IOV: Refactorizar sriov_add_vfs()”) refactorizó la eliminación de dispositivos PCI en 'sriov_del_vfs()', todavía no había bloqueo alrededor de las llamadas a 'pci_iov_remove_virtfn()'. En s390, la falta de serialización en 'sriov_disable()' puede causar doble eliminación y corrupción de la lista, observándose el siguiente rastro (modificado): PSW: 0704c00180000000 0000000c914e4b38 (klist_put+56) GPRS: 000003800313fb48 0000000000000000 0000000100000001 0000000000000001 00000000f9b520a8 0000000000000000 0000000000002fbd 00000000f4cc9480 0000000000000001 0000000000000000 0000000000000000 0000000180692828 00000000818e8000 000003800313fe2c 000003800313fb20 000003800313fad8 #0 [3800313fb20] device_del at c9158ad5c #1 [3800313fb88] pci_remove_bus_device at c915105ba #2 [3800313fbd0] pci_iov_remove_virtfn at c9152f198 #3 [3800313fc28] zpci_iov_remove_virtfn at c90fb67c0 #4 [3800313fc60] zpci_bus_remove_device at c90fb6104 #5 [3800313fca0] __zpci_event_availability at c90fb3dca #6 [3800313fd08] chsc_process_sei_nt0 at c918fe4a2 #7 [3800313fd60] crw_collect_info at c91905822 #8 [3800313fe10] kthread at c90feb390 #9 [3800313fe68] __ret_from_fork at c90f6aa64 #10 [3800313fe98] ret_from_fork at c9194f3f2. Esto se debe a que, además de que 'sriov_disable()' elimina las VF, la plataforma también genera eventos de desconexión en caliente para las VF. Siendo esta la operación inversa a los eventos de conexión en caliente generados por 'sriov_enable()' y gestionados a través de 'pdev->no_vf_scan'. Y aunque el procesamiento de eventos toma 'pci_rescan_remove_lock' y comprueba si la estructura 'pci_dev' todavía existe, la falta de sincronización hace que esta comprobación sea propensa a condiciones de carrera. Por supuesto, también pueden ser posibles otras condiciones de carrera, aunque dado que esta falta de bloqueo persistió durante tanto tiempo, las condiciones de carrera observables parecen muy raras. Incluso en s390, la corrupción de la lista solo se observó con ciertos dispositivos, ya que los eventos de la plataforma solo se activan por accesos de configuración después de la eliminación, por lo que, mientras la eliminación terminara sincrónicamente, no habría condiciones de carrera. De cualquier manera, falta el bloqueo, así que se soluciona añadiéndolo a la función auxiliar 'sriov_del_vfs()'. Al igual que en el reescaneo-eliminación de PCI, también falta el bloqueo en 'sriov_add_vfs()', incluso para el caso de error en el que se llama a 'pci_stop_and_remove_bus_device()' sin que se mantenga el bloqueo de reescaneo-eliminación de PCI. Incluso en el caso sin error, la adición de nuevos dispositivos y buses PCI debe serializarse a través del bloqueo de reescaneo-eliminación de PCI. Añadir el bloqueo necesario.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-40219 changed 2026-11-10CVE Terms of Use
NVDCVE-2025-40219 changed 2026-11-10Public domain