xen/vpci: initialize msix->next
PATCH 1/1 xen/vpci: initialize msix->next
The list was not being initialized, which could result in a crash in vpci_remove_device if no list items were added.
--- xen/drivers/vpci/msix.c | 2 ++ 1 file changed, 2 insertions(+)
xen/drivers/vpci/msix.c +2 -0
@@ -678,6 +678,8 @@ static int cf_check init_msix(struct pci_dev *pdev)if ( !msix )return -ENOMEM ; +INIT_LIST_HEAD (&msix->next); + rc =vpci_add_register (pdev->vpci, control_read, control_write,msix_control_reg (msix_offset),2 , msix);if ( rc )
Signature · 1 line
2.40.0
Quoted 2 lines · Stewart Hildebrand
The list was not being initialized, which could result in a crash in
vpci_remove_deviceif no list items were added.
Can you please point out the code path which may lead to such a crash?
xen/drivers/vpci/msix.c static int cf_check init_msix(struct pci_dev *pdev) · line 685
Quoted 11 lines
xen/drivers/vpci/msix.c +2
-0@@ -678,6 +678,8 @@ static int cf_check init_msix(struct pci_dev *pdev)if ( !msix )return -ENOMEM ; +INIT_LIST_HEAD (&msix->next); + rc =vpci_add_register (pdev->vpci, control_read, control_write,msix_control_reg (msix_offset),2 , msix);if ( rc )
The error path below here frees msix again, so can't be a problem. The only other return path from the function is after a suitable list_add().
"... if no list items were added" is misleading too - this isn't a list head, but a list element. The list head is d->arch.hvm.msix_tables.
Jan
Quoted 5 lines · Jan Beulich
Quoted 2 lines · Stewart Hildebrand
The list was not being initialized, which could result in a crash in
vpci_remove_deviceif no list items were added.Can you please point out the code path which may lead to such a crash?
It would bexen/drivers/vpci/vpci.c:59: list_del(&pdev->vpci->msix->next);
The crash was observed when msix->next had not been initialized (nor added to a list_head). It was uninitialized because ...
Quoted 6 lines
Quoted 6 lines
xen/drivers/vpci/msix.c +0
-0@@ -678,6 +678,8 @@ static int cf_check init_msix(struct pci_dev *pdev)if ( !msix )return -ENOMEM ;
Quoted 8 lines
xen/drivers/vpci/msix.c static int cf_check init_msix(struct pci_dev *pdev) · line 685
Quoted 5 lines
xen/drivers/vpci/msix.c +2
-0+INIT_LIST_HEAD (&msix->next); + rc =vpci_add_register (pdev->vpci, control_read, control_write,msix_control_reg (msix_offset),2 , msix);if ( rc )The error path below here frees msix again, so can't be a problem. The only other return path from the function is after a suitable
list_add().
... when I wrote this I had applied patch that removed the list_add() in question (on ARM). See [1].
Quoted 2 lines
"... if no list items were added" is misleading too - this isn't a list head, but a list element. The list head is
d->arch.hvm.msix_tables.
I can see now that the crash should more appropriately be resolved in the referenced patch where the crash was actually observed [1]. In the current vpci on ARM work-in-progress, there's no equivalent struct list_head msix_tables...
Sorry for the noise.