vfio/pci: Replace abort() with g_assert_not_reached()
PATCH 1/1 vfio/pci: Replace abort() with g_assert_not_reached()
This check was originally introduced in commit b3ebc10c373e ("vfio-pci: Add debug config options to disable MSI/X KVM support") as part of a debug block to retrieve the MSI/MSIX message, and was later moved by commit 0de70dc7bab1 ("vfio/pci: Rename MSI/X functions for easier tracing") into the main interrupt handling path, becoming production code.
Under normal conditions, this code path cannot be reached because the BQL serializes all handler registration, vdev->interrupt updates, and handler removal. Replace abort() with g_assert_not_reached(), which is preferred nowdays, and add a comment clarifying the purpose.
--- hw/vfio/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/vfio/pci.c +6 -1
@@ -453,7 +453,12 @@ static void vfio_msi_interrupt(void *opaque) get_msg = msi_get_message; notify = msi_notify; }else { -abort (); +/* +* Interrupt state transitions (MSI/MSI-X -> NONE/INTx) are +* protected by the BQL, and eventfd handlers are strictly +* unregistered before vdev->interrupt is modified. +*/ +g_assert_not_reached (); } msg =get_msg (pdev, nr);
Signature · 1 line
2.54.0
Quoted 40 lines · Cédric Le Goater
This check was originally introduced in commit
b3ebc10c373e("vfio-pci: Add debug config options to disable MSI/X KVM support") as part of a debug block to retrieve the MSI/MSIX message, and was later moved by commit0de70dc7bab1("vfio/pci: Rename MSI/X functions for easier tracing") into the main interrupt handling path, becoming production code.Under normal conditions, this code path cannot be reached because the BQL serializes all handler registration,
vdev->interruptupdates, and handler removal. Replaceabort()withg_assert_not_reached(), which is preferred nowdays, and add a comment clarifying the purpose.Cc Alex Williamson <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)hw/vfio/pci.c +0
-0
09acd3f6082b0a9c5223780bf7e9847b57424cf7..7ca2ff4e7c1cb570cd60d35454b33b5506dae36e100644hw/vfio/pci.c +6
-1@@ -453,7 +453,12 @@ static void vfio_msi_interrupt(void *opaque) get_msg = msi_get_message; notify = msi_notify; }else { -abort (); +/* +* Interrupt state transitions (MSI/MSI-X -> NONE/INTx) are +* protected by the BQL, and eventfd handlers are strictly +* unregistered before vdev->interrupt is modified. +*/ +g_assert_not_reached (); } msg =get_msg (pdev, nr);Signature · 1 line
2.54.0
Quoted 24 lines · Cédric Le Goater
This check was originally introduced in commit
b3ebc10c373e("vfio-pci: Add debug config options to disable MSI/X KVM support") as part of a debug block to retrieve the MSI/MSIX message, and was later moved by commit0de70dc7bab1("vfio/pci: Rename MSI/X functions for easier tracing") into the main interrupt handling path, becoming production code.Under normal conditions, this code path cannot be reached because the BQL serializes all handler registration,
vdev->interruptupdates, and handler removal. Replaceabort()withg_assert_not_reached(), which is preferred nowdays, and add a comment clarifying the purpose.Cc Alex Williamson <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)hw/vfio/pci.c +0
-0@@ -453,7 +453,12 @@ static void vfio_msi_interrupt(void *opaque) get_msg = msi_get_message;
hw/vfio/pci.c static void vfio_msi_interrupt(void *opaque) · line 462
Quoted 10 lines
hw/vfio/pci.c +6
-1notify = msi_notify; }else { -abort (); +/* +* Interrupt state transitions (MSI/MSI-X -> NONE/INTx) are +* protected by the BQL, and eventfd handlers are strictly +* unregistered before vdev->interrupt is modified. +*/ +g_assert_not_reached (); }
Could be more readable using switch(vdev->interrupt).
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Cédric Le Goater
This check was originally introduced in commit
b3ebc10c373e("vfio-pci: Add debug config options to disable MSI/X KVM support") as part of a debug block to retrieve the MSI/MSIX message, and was later moved by commit0de70dc7bab1("vfio/pci: Rename MSI/X functions for easier tracing") into the main interrupt handling path, becoming production code.Under normal conditions, this code path cannot be reached because the BQL serializes all handler registration,
vdev->interruptupdates, and handler removal. Replaceabort()withg_assert_not_reached(), which is preferred nowdays, and add a comment clarifying the purpose.Cc Alex Williamson <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/vfio/pci.c| 7 ++++++-1 file changed, 6 insertions(+), 1 deletion(-)hw/vfio/pci.c +1
-1@@ -453,7 +453,12 @@ static void vfio_msi_interrupt(void *opaque) get_msg = msi_get_message; notify = msi_notify; } else { - abort(); + /*
Quoted 9 lines
hw/vfio/pci.c static void vfio_msi_interrupt(void *opaque) · line 462
Quoted 6 lines
hw/vfio/pci.c +5
-0+* Interrupt state transitions (MSI/MSI-X -> NONE/INTx) are +* protected by the BQL, and eventfd handlers are strictly +* unregistered before vdev->interrupt is modified. +*/ + g_assert_not_reached(); }Could be more readable using
switch(vdev->interrupt).
I agree. But let's have another patch for it if you don't mind. This change is about the rational for the abort() and it was reported to the security list.
Thanks,
C.
Quoted 40 lines · Cédric Le Goater
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Cédric Le Goater
This check was originally introduced in commit
b3ebc10c373e("vfio-pci: Add debug config options to disable MSI/X KVM support") as part of a debug block to retrieve the MSI/MSIX message, and was later moved by commit0de70dc7bab1("vfio/pci: Rename MSI/X functions for easier tracing") into the main interrupt handling path, becoming production code.Under normal conditions, this code path cannot be reached because the BQL serializes all handler registration,
vdev->interruptupdates, and handler removal. Replaceabort()withg_assert_not_reached(), which is preferred nowdays, and add a comment clarifying the purpose.Cc Alex Williamson <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/vfio/pci.c| 7 ++++++-1 file changed, 6 insertions(+), 1 deletion(-)hw/vfio/pci.c +1
-1@@ -453,7 +453,12 @@ static void vfio_msi_interrupt(void *opaque) get_msg = msi_get_message; notify = msi_notify; } else { - abort(); + /*Quoted 9 lines
hw/vfio/pci.c static void vfio_msi_interrupt(void *opaque) · line 462
Quoted 6 lines
hw/vfio/pci.c +5
-0+* Interrupt state transitions (MSI/MSI-X -> NONE/INTx) are +* protected by the BQL, and eventfd handlers are strictly +* unregistered before vdev->interrupt is modified. +*/ + g_assert_not_reached(); }Could be more readable using
switch(vdev->interrupt).
Quoted 3 lines
I agree. But let's have another patch for it if you don't mind. This change is about the rational for the
abort()and it was reported to the security list.
Sure, just suggesting, not aiming to block!