public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
@ 2017-08-01  5:28 Potnuri Bharat Teja
       [not found] ` <1501565315-3183-1-git-send-email-bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Potnuri Bharat Teja @ 2017-08-01  5:28 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, bharat-ut6Up61K2wZBDgjK7y7TUQ,
	swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW

Initializing cq_context with ev_queue in create_cq(), leads to NULL pointer
dereference in ib_uverbs_comp_handler(), if application doesnot use completion
channel. This patch fixes the cq_context initialization.

Fixes: 1e7710f3f65 ("IB/core: Change completion channel to use the reworked")
Signed-off-by: Potnuri Bharat Teja <bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
---
 drivers/infiniband/core/uverbs_cmd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 2c98533a0203..8c829522d8c4 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1015,7 +1015,8 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
 	cq->uobject       = &obj->uobject;
 	cq->comp_handler  = ib_uverbs_comp_handler;
 	cq->event_handler = ib_uverbs_cq_event_handler;
-	cq->cq_context    = &ev_file->ev_queue;
+	cq->cq_context    = (cmd->comp_channel >= 0) ?
+				&ev_file->ev_queue : NULL;
 	atomic_set(&cq->usecnt, 0);
 
 	obj->uobject.object = cq;
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
       [not found] ` <1501565315-3183-1-git-send-email-bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
@ 2017-08-06  8:08   ` Matan Barak
       [not found]     ` <CAAKD3BCdeG=FkUNQjqGxEYw5Sx-TtmeRSAA8K7M43G62Qw_gbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Matan Barak @ 2017-08-06  8:08 UTC (permalink / raw)
  To: Potnuri Bharat Teja; +Cc: Doug Ledford, linux-rdma, SWise OGC

On Tue, Aug 1, 2017 at 8:28 AM, Potnuri Bharat Teja <bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org> wrote:
> Initializing cq_context with ev_queue in create_cq(), leads to NULL pointer
> dereference in ib_uverbs_comp_handler(), if application doesnot use completion
> channel. This patch fixes the cq_context initialization.
>
> Fixes: 1e7710f3f65 ("IB/core: Change completion channel to use the reworked")
> Signed-off-by: Potnuri Bharat Teja <bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 2c98533a0203..8c829522d8c4 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -1015,7 +1015,8 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
>         cq->uobject       = &obj->uobject;
>         cq->comp_handler  = ib_uverbs_comp_handler;
>         cq->event_handler = ib_uverbs_cq_event_handler;
> -       cq->cq_context    = &ev_file->ev_queue;
> +       cq->cq_context    = (cmd->comp_channel >= 0) ?
> +                               &ev_file->ev_queue : NULL;
>         atomic_set(&cq->usecnt, 0);
>
>         obj->uobject.object = cq;
> --
> 2.5.3
>

Nice catch, thanks.
I would prefer:
cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;

However, this fix is fine too.

Reviewed-by: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
       [not found]     ` <CAAKD3BCdeG=FkUNQjqGxEYw5Sx-TtmeRSAA8K7M43G62Qw_gbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-08-18 18:06       ` Doug Ledford
       [not found]         ` <1503079603.2598.33.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Ledford @ 2017-08-18 18:06 UTC (permalink / raw)
  To: Matan Barak, Potnuri Bharat Teja; +Cc: linux-rdma, SWise OGC

On Sun, 2017-08-06 at 11:08 +0300, Matan Barak wrote:
> On Tue, Aug 1, 2017 at 8:28 AM, Potnuri Bharat Teja <bharat@chelsio.c
> om> wrote:
> > Initializing cq_context with ev_queue in create_cq(), leads to NULL
> > pointer
> > dereference in ib_uverbs_comp_handler(), if application doesnot use
> > completion
> > channel. This patch fixes the cq_context initialization.
> > 
> > Fixes: 1e7710f3f65 ("IB/core: Change completion channel to use the
> > reworked")
> > Signed-off-by: Potnuri Bharat Teja <bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
> > ---
> >  drivers/infiniband/core/uverbs_cmd.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/infiniband/core/uverbs_cmd.c
> > b/drivers/infiniband/core/uverbs_cmd.c
> > index 2c98533a0203..8c829522d8c4 100644
> > --- a/drivers/infiniband/core/uverbs_cmd.c
> > +++ b/drivers/infiniband/core/uverbs_cmd.c
> > @@ -1015,7 +1015,8 @@ static struct ib_ucq_object *create_cq(struct
> > ib_uverbs_file *file,
> >         cq->uobject       = &obj->uobject;
> >         cq->comp_handler  = ib_uverbs_comp_handler;
> >         cq->event_handler = ib_uverbs_cq_event_handler;
> > -       cq->cq_context    = &ev_file->ev_queue;
> > +       cq->cq_context    = (cmd->comp_channel >= 0) ?
> > +                               &ev_file->ev_queue : NULL;
> >         atomic_set(&cq->usecnt, 0);
> > 
> >         obj->uobject.object = cq;
> > --
> > 2.5.3
> > 
> 
> Nice catch, thanks.
> I would prefer:
> cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;
> 
> However, this fix is fine too.
> 
> Reviewed-by: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

I agree, I like your solution better.  Patch fixed up and applied.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
       [not found]         ` <1503079603.2598.33.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2017-08-18 20:51           ` Steve Wise
  2017-08-21 19:11             ` Steve Wise
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Wise @ 2017-08-18 20:51 UTC (permalink / raw)
  To: 'Doug Ledford', 'Matan Barak',
	'Potnuri Bharat Teja'
  Cc: 'linux-rdma'

> 
> I agree, I like your solution better.  Patch fixed up and applied.
> 

Hey Doug, I see this in your -next branch, but it needs to hit 4.13-rc and stable, as it is a fatal regression that breaks user mode rdma applications.

Thanks,

Steve.


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
  2017-08-18 20:51           ` Steve Wise
@ 2017-08-21 19:11             ` Steve Wise
  2017-08-22  0:44               ` Doug Ledford
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Wise @ 2017-08-21 19:11 UTC (permalink / raw)
  To: 'Doug Ledford', 'Matan Barak',
	'Potnuri Bharat Teja'
  Cc: 'linux-rdma'

ping...

> 
> >
> > I agree, I like your solution better.  Patch fixed up and applied.
> >
> 
> Hey Doug, I see this in your -next branch, but it needs to hit 4.13-rc and stable, as it
> is a fatal regression that breaks user mode rdma applications.
> 
> Thanks,
> 
> Steve.
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately
  2017-08-21 19:11             ` Steve Wise
@ 2017-08-22  0:44               ` Doug Ledford
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Ledford @ 2017-08-22  0:44 UTC (permalink / raw)
  To: Steve Wise, 'Matan Barak', 'Potnuri Bharat Teja'
  Cc: 'linux-rdma'


[-- Attachment #1.1: Type: text/plain, Size: 524 bytes --]

On 8/21/2017 3:11 PM, Steve Wise wrote:
> ping...
> 
>>
>>>
>>> I agree, I like your solution better.  Patch fixed up and applied.
>>>
>>
>> Hey Doug, I see this in your -next branch, but it needs to hit 4.13-rc and stable, as it
>> is a fatal regression that breaks user mode rdma applications.

OK, I'll get it into -rc then.


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2017-08-22  0:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01  5:28 [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately Potnuri Bharat Teja
     [not found] ` <1501565315-3183-1-git-send-email-bharat-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2017-08-06  8:08   ` Matan Barak
     [not found]     ` <CAAKD3BCdeG=FkUNQjqGxEYw5Sx-TtmeRSAA8K7M43G62Qw_gbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-18 18:06       ` Doug Ledford
     [not found]         ` <1503079603.2598.33.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-08-18 20:51           ` Steve Wise
2017-08-21 19:11             ` Steve Wise
2017-08-22  0:44               ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox