xen/arm: domain_vgic_init: Avoid double free on shared_irqs
PATCH 1/1 xen/arm: domain_vgic_init: Avoid double free on shared_irqs
When the function domain_vgic_init is failing to initialize pending_irqs, it will free shared_irqs. Few call later, domain_vgic_free will be called an try to free a second time the same variable. This will result to a double free.
Remove the free in domain_vgic_init and rely on domain_vgic_free to correctly release the memory.
---
This patch should be backported to Xen 4.4.
--- xen/arch/arm/vgic.c | 3 --- 1 file changed, 3 deletions(-)
xen/arch/arm/vgic.c +0 -3
@@ -84,10 +84,7 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis) d->arch.vgic.pending_irqs = xzalloc_array(struct pending_irq, d->arch.vgic.nr_spis);if ( d->arch.vgic.pending_irqs ==NULL ) - { -xfree (d->arch.vgic.shared_irqs);return -ENOMEM ; - }for (i=0 ; i<d->arch.vgic.nr_spis; i++) {
Signature · 1 line
1.7.10.4
Hi Ian and Stefano,
Ping?
Quoted 33 lines · Julien Grall
When the function
domain_vgic_initis failing to initializepending_irqs, it will freeshared_irqs. Few call later,domain_vgic_freewill be called an try to free a second time the same variable. This will result to a double free.Remove the free in
domain_vgic_initand rely ondomain_vgic_freeto correctly release the memory.Signed-off-by Julien Grall <[email protected]>---
This patch should be backported to Xen 4.4.
--- xen/arch/arm/vgic.c | 3 --- 1 file changed, 3 deletions(-)xen/arch/arm/vgic.c +0
-3@@ -84,10 +84,7 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis) d->arch.vgic.pending_irqs = xzalloc_array(struct pending_irq, d->arch.vgic.nr_spis);if ( d->arch.vgic.pending_irqs ==NULL ) - { -xfree (d->arch.vgic.shared_irqs);return -ENOMEM ; - }for (i=0 ; i<d->arch.vgic.nr_spis; i++) {
Signature · 1 line
Julien Grall
Sorry, this one wasn't in my queue foirld for some reason. Acked + applied.
Quoted 39 lines · Julien Grall
Hi Ian and Stefano,
Ping?
Quoted 33 lines · Julien Grall
When the function
domain_vgic_initis failing to initializepending_irqs, it will freeshared_irqs. Few call later,domain_vgic_freewill be called an try to free a second time the same variable. This will result to a double free.Remove the free in
domain_vgic_initand rely ondomain_vgic_freeto correctly release the memory.Signed-off-by Julien Grall <[email protected]>---
This patch should be backported to Xen 4.4.
--- xen/arch/arm/vgic.c | 3 --- 1 file changed, 3 deletions(-)xen/arch/arm/vgic.c +0
-3@@ -84,10 +84,7 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis) d->arch.vgic.pending_irqs = xzalloc_array(struct pending_irq, d->arch.vgic.nr_spis);if ( d->arch.vgic.pending_irqs ==NULL ) - { -xfree (d->arch.vgic.shared_irqs);return -ENOMEM ; - }for (i=0 ; i<d->arch.vgic.nr_spis; i++) {
Quoted 2 lines · Ian Campbell
Sorry, this one wasn't in my queue foirld for some reason. Acked + applied.
Thanks! The double free is also present on Xen 4.4. Can you put it on your backport list?
Regards,
Signature · 1 line
Julien Grall
Quoted 6 lines · Julien Grall
Quoted 2 lines · Ian Campbell
Sorry, this one wasn't in my queue foirld for some reason. Acked + applied.
Thanks! The double free is also present on Xen 4.4. Can you put it on your backport list?
It's already there, I should have said.
Ian.
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Julien Grall
Quoted 2 lines · Ian Campbell
Sorry, this one wasn't in my queue foirld for some reason. Acked + applied.
Thanks! The double free is also present on Xen 4.4. Can you put it on your backport list?
It's already there, I should have said.
Thanks!
Signature · 1 line
Julien Grall