LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines
@ 2015-02-26  5:52 Juergen Gross
  2015-03-06 12:32 ` Juergen Gross
  2015-03-06 13:18 ` [Xen-devel] " David Vrabel
  0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2015-02-26  5:52 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel, boris.ostrovsky
  Cc: Juergen Gross

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>
---
 drivers/xen/events/events_base.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index b4bca2d..70fba97 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -526,20 +526,26 @@ static unsigned int __startup_pirq(unsigned int irq)
 	pirq_query_unmask(irq);
 
 	rc = set_evtchn_to_irq(evtchn, irq);
-	if (rc != 0) {
-		pr_err("irq%d: Failed to set port to irq mapping (%d)\n",
-		       irq, rc);
-		xen_evtchn_close(evtchn);
-		return 0;
-	}
+	if (rc)
+		goto err;
+
 	bind_evtchn_to_cpu(evtchn, 0);
 	info->evtchn = evtchn;
 
+	rc = xen_evtchn_port_setup(info);
+	if (rc)
+		goto err;
+
 out:
 	unmask_evtchn(evtchn);
 	eoi_pirq(irq_get_irq_data(irq));
 
 	return 0;
+
+err:
+	pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc);
+	xen_evtchn_close(evtchn);
+	return 0;
 }
 
 static unsigned int startup_pirq(struct irq_data *data)
-- 
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines
  2015-02-26  5:52 [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines Juergen Gross
@ 2015-03-06 12:32 ` Juergen Gross
  2015-03-06 13:18 ` [Xen-devel] " David Vrabel
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2015-03-06 12:32 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel, boris.ostrovsky

Ping?

On 02/26/2015 06:52 AM, Juergen Gross wrote:
> 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>
> ---
>   drivers/xen/events/events_base.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
> index b4bca2d..70fba97 100644
> --- a/drivers/xen/events/events_base.c
> +++ b/drivers/xen/events/events_base.c
> @@ -526,20 +526,26 @@ static unsigned int __startup_pirq(unsigned int irq)
>   	pirq_query_unmask(irq);
>
>   	rc = set_evtchn_to_irq(evtchn, irq);
> -	if (rc != 0) {
> -		pr_err("irq%d: Failed to set port to irq mapping (%d)\n",
> -		       irq, rc);
> -		xen_evtchn_close(evtchn);
> -		return 0;
> -	}
> +	if (rc)
> +		goto err;
> +
>   	bind_evtchn_to_cpu(evtchn, 0);
>   	info->evtchn = evtchn;
>
> +	rc = xen_evtchn_port_setup(info);
> +	if (rc)
> +		goto err;
> +
>   out:
>   	unmask_evtchn(evtchn);
>   	eoi_pirq(irq_get_irq_data(irq));
>
>   	return 0;
> +
> +err:
> +	pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc);
> +	xen_evtchn_close(evtchn);
> +	return 0;
>   }
>
>   static unsigned int startup_pirq(struct irq_data *data)
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xen-devel] [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines
  2015-02-26  5:52 [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines Juergen Gross
  2015-03-06 12:32 ` Juergen Gross
@ 2015-03-06 13:18 ` David Vrabel
  1 sibling, 0 replies; 3+ messages in thread
From: David Vrabel @ 2015-03-06 13:18 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, konrad.wilk,
	david.vrabel, boris.ostrovsky

On 26/02/15 05:52, Juergen Gross wrote:
> 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.

Applied to stable/for-linus-4.0 and tagged for stable, thanks.

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-06 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26  5:52 [PATCH] xen: avoid NULL pointer dereference in dom0 on large machines Juergen Gross
2015-03-06 12:32 ` Juergen Gross
2015-03-06 13:18 ` [Xen-devel] " David Vrabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).