Skip to contentSkip to conversation

xen/arm: domain_vgic_init: Avoid double free on shared_irqs

PATCH In review Julien Grall 2 participants 6 messages Jul 25, 2014 – Sep 10, 2014

lore
Share & tools
lore
#0 lore raw

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
index aba613b..edbb71a 100644
@@ -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
#1 lore raw

Hi Ian and Stefano,

Ping?

Quoted 33 lines · Julien Grall

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
index aba613b..edbb71a 100644
@@ -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
#2 lore raw

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_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
index aba613b..edbb71a 100644
@@ -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++)
      {
#3 lore raw
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
#4 lore raw
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.

#5 lore raw
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