linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
@ 2016-06-29 18:55 Ian Munsie
  2016-06-29 22:28 ` Andrew Donnellan
  2016-07-11 10:19 ` Michael Ellerman
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Munsie @ 2016-06-29 18:55 UTC (permalink / raw)
  To: Michael Ellerman, mikey, linuxppc-dev, Frederic Barrat, Huy Nguyen
  Cc: Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

If a kernel context is initialised and does not have any AFU interrupts
allocated it will cause a NULL pointer dereference when the context is
detached since the irq_names list will not have been initialised.

Move the initialisation of the irq_names list into the cxl_context_init
routine so that it will be valid for the entire lifetime of the context
and will not cause a NULL pointer dereference.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 drivers/misc/cxl/context.c | 2 ++
 drivers/misc/cxl/irq.c     | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 26d206b..edbb99e 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -67,6 +67,8 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master,
 	ctx->pending_fault = false;
 	ctx->pending_afu_err = false;
 
+	INIT_LIST_HEAD(&ctx->irq_names);
+
 	/*
 	 * When we have to destroy all contexts in cxl_context_detach_all() we
 	 * end up with afu_release_irqs() called from inside a
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index 8def455..f3a7d4a 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -260,9 +260,6 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
 	else
 		alloc_count = count + 1;
 
-	/* Initialize the list head to hold irq names */
-	INIT_LIST_HEAD(&ctx->irq_names);
-
 	if ((rc = cxl_ops->alloc_irq_ranges(&ctx->irqs, ctx->afu->adapter,
 							alloc_count)))
 		return rc;
-- 
2.8.1

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

* Re: [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
  2016-06-29 18:55 [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts Ian Munsie
@ 2016-06-29 22:28 ` Andrew Donnellan
  2016-06-30  5:00   ` Michael Ellerman
  2016-07-11 10:19 ` Michael Ellerman
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Donnellan @ 2016-06-29 22:28 UTC (permalink / raw)
  To: Ian Munsie, Michael Ellerman, mikey, linuxppc-dev,
	Frederic Barrat, Huy Nguyen

On 30/06/16 04:55, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
>
> If a kernel context is initialised and does not have any AFU interrupts
> allocated it will cause a NULL pointer dereference when the context is
> detached since the irq_names list will not have been initialised.
>
> Move the initialisation of the irq_names list into the cxl_context_init
> routine so that it will be valid for the entire lifetime of the context
> and will not cause a NULL pointer dereference.
>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

As it's nice having your machine not crash on every shutdown...

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

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

* Re: [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
  2016-06-29 22:28 ` Andrew Donnellan
@ 2016-06-30  5:00   ` Michael Ellerman
  2016-06-30  5:15     ` Andrew Donnellan
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2016-06-30  5:00 UTC (permalink / raw)
  To: Andrew Donnellan, Ian Munsie, mikey, linuxppc-dev,
	Frederic Barrat, Huy Nguyen

On Thu, 2016-06-30 at 08:28 +1000, Andrew Donnellan wrote:
> On 30/06/16 04:55, Ian Munsie wrote:
> > 
> > From: Ian Munsie <imunsie@au1.ibm.com>
> > 
> > If a kernel context is initialised and does not have any AFU interrupts
> > allocated it will cause a NULL pointer dereference when the context is
> > detached since the irq_names list will not have been initialised.
> > 
> > Move the initialisation of the irq_names list into the cxl_context_init
> > routine so that it will be valid for the entire lifetime of the context
> > and will not cause a NULL pointer dereference.
> > 
> > Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

> As it's nice having your machine not crash on every shutdown...

Fixes: ????

cheers

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

* Re: [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
  2016-06-30  5:00   ` Michael Ellerman
@ 2016-06-30  5:15     ` Andrew Donnellan
  2016-06-30  6:24       ` Ian Munsie
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Donnellan @ 2016-06-30  5:15 UTC (permalink / raw)
  To: Michael Ellerman, Ian Munsie, mikey, linuxppc-dev,
	Frederic Barrat, Huy Nguyen

On 30/06/16 15:00, Michael Ellerman wrote:
> On Thu, 2016-06-30 at 08:28 +1000, Andrew Donnellan wrote:
>> On 30/06/16 04:55, Ian Munsie wrote:
>>>
>>> From: Ian Munsie <imunsie@au1.ibm.com>
>>>
>>> If a kernel context is initialised and does not have any AFU interrupts
>>> allocated it will cause a NULL pointer dereference when the context is
>>> detached since the irq_names list will not have been initialised.
>>>
>>> Move the initialisation of the irq_names list into the cxl_context_init
>>> routine so that it will be valid for the entire lifetime of the context
>>> and will not cause a NULL pointer dereference.
>>>
>>> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
>
>> As it's nice having your machine not crash on every shutdown...
>
> Fixes: ????

Ian can correct me if I'm wrong, but I suspect this doesn't affect 
cxlflash (the only current user of the cxl kernel API) - this issue was 
hit while working on CAPI support for mlx5.

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

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

* Re: [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
  2016-06-30  5:15     ` Andrew Donnellan
@ 2016-06-30  6:24       ` Ian Munsie
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Munsie @ 2016-06-30  6:24 UTC (permalink / raw)
  To: andrew.donnellan
  Cc: Michael Ellerman, mikey, linuxppc-dev, Frederic Barrat, Huy Nguyen

Excerpts from andrew.donnellan's message of 2016-06-30 15:15:02 +1000:
> On 30/06/16 15:00, Michael Ellerman wrote:
> > On Thu, 2016-06-30 at 08:28 +1000, Andrew Donnellan wrote:
> >> On 30/06/16 04:55, Ian Munsie wrote:
> >>>
> >>> From: Ian Munsie <imunsie@au1.ibm.com>
> >>>
> >>> If a kernel context is initialised and does not have any AFU interrupts
> >>> allocated it will cause a NULL pointer dereference when the context is
> >>> detached since the irq_names list will not have been initialised.
> >>>
> >>> Move the initialisation of the irq_names list into the cxl_context_init
> >>> routine so that it will be valid for the entire lifetime of the context
> >>> and will not cause a NULL pointer dereference.
> >>>
> >>> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> >
> >> As it's nice having your machine not crash on every shutdown...
> >
> > Fixes: ????
> 
> Ian can correct me if I'm wrong, but I suspect this doesn't affect 
> cxlflash (the only current user of the cxl kernel API) - this issue was 
> hit while working on CAPI support for mlx5.

Correct - no current user hits this bug, but the upcoming mlx5 support
does because of the way it uses interrupts.

-Ian

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

* Re: cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts
  2016-06-29 18:55 [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts Ian Munsie
  2016-06-29 22:28 ` Andrew Donnellan
@ 2016-07-11 10:19 ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2016-07-11 10:19 UTC (permalink / raw)
  To: Ian Munsie, mikey, linuxppc-dev, Frederic Barrat, Huy Nguyen; +Cc: Ian Munsie

On Wed, 2016-29-06 at 18:55:17 UTC, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> If a kernel context is initialised and does not have any AFU interrupts
> allocated it will cause a NULL pointer dereference when the context is
> detached since the irq_names list will not have been initialised.
> 
> Move the initialisation of the irq_names list into the cxl_context_init
> routine so that it will be valid for the entire lifetime of the context
> and will not cause a NULL pointer dereference.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f5c9df9a442f586b1839476272

cheers

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

end of thread, other threads:[~2016-07-11 10:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 18:55 [PATCH] cxl: Fix NULL pointer dereference on kernel contexts with no AFU interrupts Ian Munsie
2016-06-29 22:28 ` Andrew Donnellan
2016-06-30  5:00   ` Michael Ellerman
2016-06-30  5:15     ` Andrew Donnellan
2016-06-30  6:24       ` Ian Munsie
2016-07-11 10:19 ` Michael Ellerman

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).