Skip to content

Commit 85e40b0

Browse files
jgross1David Vrabel
authored andcommitted
xen/events: avoid NULL pointer dereference in dom0 on large machines
Using the pvops kernel a NULL pointer dereference was detected on a large machine (144 processors) when booting as dom0 in evtchn_fifo_unmask() during assignment of a pirq. The event channel in question was the first to need a new entry in event_array[] in events_fifo.c. Unfortunately xen_irq_info_pirq_setup() is called with evtchn being 0 for a new pirq and the real event channel number is assigned to the pirq only during __startup_pirq(). It is mandatory to call xen_evtchn_port_setup() after assigning the event channel number to the pirq to make sure all memory needed for the event channel is allocated. Signed-off-by: Juergen Gross <jgross@suse.com> Cc: <stable@vger.kernel.org> # 3.14+ Signed-off-by: David Vrabel <david.vrabel@citrix.com>
1 parent 604b91f commit 85e40b0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/xen/events/events_base.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,26 @@ static unsigned int __startup_pirq(unsigned int irq)
526526
pirq_query_unmask(irq);
527527

528528
rc = set_evtchn_to_irq(evtchn, irq);
529-
if (rc != 0) {
530-
pr_err("irq%d: Failed to set port to irq mapping (%d)\n",
531-
irq, rc);
532-
xen_evtchn_close(evtchn);
533-
return 0;
534-
}
529+
if (rc)
530+
goto err;
531+
535532
bind_evtchn_to_cpu(evtchn, 0);
536533
info->evtchn = evtchn;
537534

535+
rc = xen_evtchn_port_setup(info);
536+
if (rc)
537+
goto err;
538+
538539
out:
539540
unmask_evtchn(evtchn);
540541
eoi_pirq(irq_get_irq_data(irq));
541542

542543
return 0;
544+
545+
err:
546+
pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc);
547+
xen_evtchn_close(evtchn);
548+
return 0;
543549
}
544550

545551
static unsigned int startup_pirq(struct irq_data *data)

0 commit comments

Comments
 (0)