Skip to content

Commit a5b8311

Browse files
jgross1gregkh
authored andcommitted
xen/events: avoid NULL pointer dereference in dom0 on large machines
commit 85e40b0539b24518c8bdf63e2605c8522377d00f upstream. 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> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 472cd1f commit a5b8311

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

drivers/xen/events/events_base.c

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

549549
rc = set_evtchn_to_irq(evtchn, irq);
550-
if (rc != 0) {
551-
pr_err("irq%d: Failed to set port to irq mapping (%d)\n",
552-
irq, rc);
553-
xen_evtchn_close(evtchn);
554-
return 0;
555-
}
550+
if (rc)
551+
goto err;
552+
556553
bind_evtchn_to_cpu(evtchn, 0);
557554
info->evtchn = evtchn;
558555

556+
rc = xen_evtchn_port_setup(info);
557+
if (rc)
558+
goto err;
559+
559560
out:
560561
unmask_evtchn(evtchn);
561562
eoi_pirq(irq_get_irq_data(irq));
562563

563564
return 0;
565+
566+
err:
567+
pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc);
568+
xen_evtchn_close(evtchn);
569+
return 0;
564570
}
565571

566572
static unsigned int startup_pirq(struct irq_data *data)

0 commit comments

Comments
 (0)