Skip to contentSkip to conversation

xen/arm: domain_vgic_init: Check xzalloc_* return

PATCH In review Julien Grall 4 participants 7 messages Mar 20, 2014 – Mar 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: domain_vgic_init: Check xzalloc_* return

The allocations for shared_irqs and pending_irqs are not checked and use later. This may lead to a Xen segfault if the hypervisor run out of memory.

---
This patch should be backported to Xen 4.4

---
 xen/arch/arm/vgic.c |    9 +++++++++
 1 file changed, 9 insertions(+)
xen/arch/arm/vgic.c +9 -0
index 553411d..9fc9586 100644
@@ -89,8 +89,17 @@ int domain_vgic_init(struct domain *d)
 
     d->arch.vgic.shared_irqs =
         xzalloc_array(struct vgic_irq_rank, DOMAIN_NR_RANKS(d));
+    if ( d->arch.vgic.shared_irqs == NULL )
+        return -ENOMEM;
+
     d->arch.vgic.pending_irqs =
         xzalloc_array(struct pending_irq, d->arch.vgic.nr_lines);
+    if ( d->arch.vgic.pending_irqs == NULL )
+    {
+        xfree(d->arch.vgic.shared_irqs);
+        return -ENOMEM;
+    }
+
     for (i=0; i<d->arch.vgic.nr_lines; i++)
     {
         INIT_LIST_HEAD(&d->arch.vgic.pending_irqs[i].inflight);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 4 lines · Julien Grall

The allocations for shared_irqs and pending_irqs are not checked and use later. This may lead to a Xen segfault if the hypervisor run out of memory.

Acked + applied.

Quoted 2 lines

---
This patch should be backported to Xen 4.4

I've added it to my notes, but also CCing Jan since I guess he will be the one to actually do it.

Ian.

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 4 lines · Julien Grall

The allocations for shared_irqs and pending_irqs are not checked and use later. This may lead to a Xen segfault if the hypervisor run out of memory.

Quoted 7 lines

Acked + applied.

Quoted 2 lines

---
This patch should be backported to Xen 4.4

I've added it to my notes, but also CCing Jan since I guess he will be the one to actually do it.

That's something we need to discuss I think: Since I'm not actively using the ARM port, I'm not sure we wouldn't introduce unnecessary risks if I did the backports. Therefore I'd like to put up for discussion whether one of the ARM maintainers wouldn't be in a better position to do this now that we need to do backports there - both in terms of tracking what needs backporting as well as actually applying them.

Jan

#3 lore raw
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 4 lines · Julien Grall

The allocations for shared_irqs and pending_irqs are not checked and use later. This may lead to a Xen segfault if the hypervisor run out of memory.

Acked + applied.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

---
This patch should be backported to Xen 4.4

I've added it to my notes, but also CCing Jan since I guess he will be the one to actually do it.

That's something we need to discuss I think:

I suspected it might be ;-)

Quoted 6 lines

Since I'm not actively
using the ARM port, I'm not sure we wouldn't introduce unnecessary risks if I did the backports. Therefore I'd like to put up for discussion whether one of the ARM maintainers wouldn't be in a better position to do this now that we need to do backports there - both in terms of tracking what needs backporting as well as actually applying them.

I'd be happy to do both of these things.

Ian, For ARM only toolstack patches how would you prefer to proceed? I'm happy either way.

Ian.

#4 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 6 lines · Jan Beulich

Since I'm not actively
using the ARM port, I'm not sure we wouldn't introduce unnecessary risks if I did the backports. Therefore I'd like to put up for discussion whether one of the ARM maintainers wouldn't be in a better position to do this now that we need to do backports there - both in terms of tracking what needs backporting as well as actually applying them.

I'd be happy to do both of these things.

Thanks - so be it then.

Jan

#5 lore raw
In reply to Ian Campbell

Ian Campbell writes ("Re: [PATCH] xen/arm: domain_vgic_init: Check xzalloc_* return"):

Quoted 2 lines

Ian, For ARM only toolstack patches how would you prefer to proceed? I'm happy either way.

If it's to ARM-specific code, you should do it; otherwise, I'll do it. And if it overlaps or is confusing we can talk about it :-).

Thanks,
Ian.

#6 lore raw
Quoted 6 lines · Ian Jackson

Ian Campbell writes ("Re: [PATCH] xen/arm: domain_vgic_init: Check xzalloc_* return"):

Quoted 2 lines

Ian, For ARM only toolstack patches how would you prefer to proceed? I'm happy either way.

If it's to ARM-specific code, you should do it; otherwise, I'll do it. And if it overlaps or is confusing we can talk about it :-).

Deal!