passthrough/amd: avoid reading an uninitialized variable.
PATCH 1/1 passthrough/amd: avoid reading an uninitialized variable.
update_intremap_entry_from_msi() doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.
---
I'm not sure whether we ought to be writing some default value instead. Happy to respin if someone knowledgeable can advise.
--- xen/drivers/passthrough/amd/iommu_intr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xen/drivers/passthrough/amd/iommu_intr.c +3 -2
@@ -529,10 +529,11 @@ int amd_iommu_msi_msg_update_ire( }while (PCI_SLOT (bdf) ==PCI_SLOT (pdev->devfn) );if ( !rc ) + {for ( i =1 ; i < nr; ++i ) msi_desc[i].remap_index = msi_desc->remap_index + i; - - msg->data = data; + msg->data = data; + }return rc; }
Signature · 1 line
2.1.4
Quoted 7 lines · Tim Deegan
update_intremap_entry_from_msi()doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.Signed-off-by Tim Deegan <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>
This looks curiously familiar.
http://lists.xen.org/archives/html/xen-devel/2015-03/msg03679.html
I was meaning to get around to submitting it as a formal patch, but you have definitely beaten me to it :)
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 16.04.15 at 19:19, <[email protected]> wrote:
Quoted 7 lines · Tim Deegan
update_intremap_entry_from_msi()doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.Signed-off-by Tim Deegan <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>
Quoted 6 lines
This looks curiously familiar.
http://lists.xen.org/archives/html/xen-devel/2015-03/msg03679.html
I was meaning to get around to submitting it as a formal patch, but you have definitely beaten me to it :)
But sadly it didn't help with the issue Sander reported (and I also didn't expect it to, as errors here should cause the caller to not use msg at all, and the regressing patch didn't alter anything that could have caused errors to surface where none where seen before). Still the patch is a good one as correcting a language spec violation.
Jan
Quoted 7 lines · Tim Deegan
update_intremap_entry_from_msi()doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.Signed-off-by Tim Deegan <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>
CC-ing Sander who I believe saw this problem.
http://lists.xen.org/archives/html/xen-devel/2015-03/msg03679.html
Quoted 33 lines
---
I'm not sure whether we ought to be writing some default value instead. Happy to respin if someone knowledgeable can advise.--- xen/drivers/passthrough/amd/iommu_intr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -529,10 +529,11 @@ int amd_iommu_msi_msg_update_ire( }while (PCI_SLOT (bdf) ==PCI_SLOT (pdev->devfn) );if ( !rc ) + {for ( i =1 ; i < nr; ++i ) msi_desc[i].remap_index = msi_desc->remap_index + i; - - msg->data = data; + msg->data = data; + }return rc; }Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 7 lines · Tim Deegan
update_intremap_entry_from_msi()doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.Signed-off-by Tim Deegan <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>
AMD maintainers: can you ack/nack this please?
Cheers,
Tim.
Suthikulpanit, Suravee
Acked-byQuoted 9 lines · Tim Deegan
Quoted 7 lines · Tim Deegan
update_intremap_entry_from_msi()doesn't write to its data pointer on some error paths, so we copying that variable into the msg would count as undefined behaviour.Signed-off-by Tim Deegan <[email protected]>Cc Suravee Suthikulpanit <[email protected]>Cc Aravind Gopalakrishnan <[email protected]>
Quoted 5 lines
AMD maintainers: can you ack/nack this please?
Cheers,
Tim.
Thanks,
Suravee