linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix modify_qp failure
@ 2017-07-14 14:41 Mustafa Ismail
  2017-07-14 14:41 ` [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number Mustafa Ismail
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Mustafa Ismail @ 2017-07-14 14:41 UTC (permalink / raw)
  To: linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, shiraz.saleem

Commit 5ecce4c9b17b("Check port number supplied by user verbs cmds") causes
modify_qp to fail because port_num is only valid when the mask is set.

Additionally, for iWARP, the port_num is not initialized which also
causes modify_qp to fail.

This series fixes both issues.

Changes to V2:
* Add reviewed-by
* Cc: <stable@vger.kernel.org>

Mustafa Ismail (2):
  RDMA/uverbs: Fix the check for port number
  RDMA/core: Initialize port_num in qp_attr

 drivers/infiniband/core/cma.c        | 2 ++
 drivers/infiniband/core/uverbs_cmd.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

-- 
2.7.4

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

* [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number
  2017-07-14 14:41 [PATCH v2 0/2] Fix modify_qp failure Mustafa Ismail
@ 2017-07-14 14:41 ` Mustafa Ismail
  2017-07-17 19:10   ` Marciniszyn, Mike
  2017-07-14 14:41 ` [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr Mustafa Ismail
  2017-07-22 18:17 ` [PATCH v2 0/2] Fix modify_qp failure Doug Ledford
  2 siblings, 1 reply; 9+ messages in thread
From: Mustafa Ismail @ 2017-07-14 14:41 UTC (permalink / raw)
  To: linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, shiraz.saleem

The port number is only valid if IB_QP_PORT is set in the mask.
So only check port number if it is valid to prevent modify_qp from
failing due to an invalid port number.

Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
Cc: <stable@vger.kernel.org> # v2.6.14+
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
---
 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 8ba9bfb..19de068 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1935,7 +1935,8 @@ static int modify_qp(struct ib_uverbs_file *file,
 		goto out;
 	}
 
-	if (!rdma_is_port_valid(qp->device, cmd->base.port_num)) {
+	if ((cmd->base.attr_mask & IB_QP_PORT) &&
+	    !rdma_is_port_valid(qp->device, cmd->base.port_num)) {
 		ret = -EINVAL;
 		goto release_qp;
 	}
-- 
2.7.4

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

* [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
  2017-07-14 14:41 [PATCH v2 0/2] Fix modify_qp failure Mustafa Ismail
  2017-07-14 14:41 ` [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number Mustafa Ismail
@ 2017-07-14 14:41 ` Mustafa Ismail
  2017-07-17 19:10   ` Marciniszyn, Mike
  2017-07-22 18:17 ` [PATCH v2 0/2] Fix modify_qp failure Doug Ledford
  2 siblings, 1 reply; 9+ messages in thread
From: Mustafa Ismail @ 2017-07-14 14:41 UTC (permalink / raw)
  To: linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, shiraz.saleem

Initialize the port_num for iWARP in rdma_init_qp_attr.

Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
Cc: <stable@vger.kernel.org> # v2.6.14+
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
---
 drivers/infiniband/core/cma.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 31bb82d..d65a093 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1044,6 +1044,8 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
 		} else
 			ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
 						 qp_attr_mask);
+		qp_attr->port_num = id_priv->id.port_num;
+		*qp_attr_mask |= IB_QP_PORT;
 	} else
 		ret = -ENOSYS;
 
-- 
2.7.4

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

* RE: [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number
  2017-07-14 14:41 ` [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number Mustafa Ismail
@ 2017-07-17 19:10   ` Marciniszyn, Mike
  0 siblings, 0 replies; 9+ messages in thread
From: Marciniszyn, Mike @ 2017-07-17 19:10 UTC (permalink / raw)
  To: Ismail, Mustafa, linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, Saleem, Shiraz

> Subject: [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number
> 
> The port number is only valid if IB_QP_PORT is set in the mask.
> So only check port number if it is valid to prevent modify_qp from
> failing due to an invalid port number.
> 
> Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> Cc: <stable@vger.kernel.org> # v2.6.14+
> Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>

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

* RE: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
  2017-07-14 14:41 ` [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr Mustafa Ismail
@ 2017-07-17 19:10   ` Marciniszyn, Mike
  2017-07-19  8:09     ` Kalderon, Michal
  0 siblings, 1 reply; 9+ messages in thread
From: Marciniszyn, Mike @ 2017-07-17 19:10 UTC (permalink / raw)
  To: Ismail, Mustafa, linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, Saleem, Shiraz

> Subject: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
> 
> Initialize the port_num for iWARP in rdma_init_qp_attr.
> 
> Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> Cc: <stable@vger.kernel.org> # v2.6.14+
> Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>

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

* RE: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
  2017-07-17 19:10   ` Marciniszyn, Mike
@ 2017-07-19  8:09     ` Kalderon, Michal
  2017-07-19 14:38       ` Ismail, Mustafa
  0 siblings, 1 reply; 9+ messages in thread
From: Kalderon, Michal @ 2017-07-19  8:09 UTC (permalink / raw)
  To: Marciniszyn, Mike, Ismail, Mustafa, linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, Saleem, Shiraz, Amrani, Ram

> From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> owner@vger.kernel.org] On Behalf Of Marciniszyn, Mike
> > Initialize the port_num for iWARP in rdma_init_qp_attr.
> >
> > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > Cc: <stable@vger.kernel.org> # v2.6.14+
> > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> 
Why is the second patch required if you only validate the port_num if the IB_QP_PORT mask is on? 
Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number, this one seems
redundant. 

Thanks,
Michal

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

* RE: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
  2017-07-19  8:09     ` Kalderon, Michal
@ 2017-07-19 14:38       ` Ismail, Mustafa
  2017-07-19 15:09         ` Kalderon, Michal
  0 siblings, 1 reply; 9+ messages in thread
From: Ismail, Mustafa @ 2017-07-19 14:38 UTC (permalink / raw)
  To: Kalderon, Michal, Marciniszyn, Mike, linux-rdma, dledford
  Cc: swise, linux-kernel, stable, e1000-rdma, Saleem, Shiraz, Amrani, Ram

> -----Original Message-----
> From: Kalderon, Michal [mailto:Michal.Kalderon@cavium.com]
> Sent: Wednesday, July 19, 2017 3:10 AM
> To: Marciniszyn, Mike <mike.marciniszyn@intel.com>; Ismail, Mustafa
> <mustafa.ismail@intel.com>; linux-rdma@vger.kernel.org;
> dledford@redhat.com
> Cc: swise@opengridcomputing.com; linux-kernel@vger.kernel.org;
> stable@vger.kernel.org; e1000-rdma@lists.sourceforge.net; Saleem, Shiraz
> <shiraz.saleem@intel.com>; Amrani, Ram <Ram.Amrani@cavium.com>
> Subject: RE: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
> 
> > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> > owner@vger.kernel.org] On Behalf Of Marciniszyn, Mike
> > > Initialize the port_num for iWARP in rdma_init_qp_attr.
> > >
> > > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > > Cc: <stable@vger.kernel.org> # v2.6.14+
> > > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> >
> Why is the second patch required if you only validate the port_num if the
> IB_QP_PORT mask is on?
> Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port
> number, this one seems redundant.
Strictly speaking it is not required, but we felt it safer to always return a valid port number
as is done in the IB case.

Regards,

Mustafa

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

* Re: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
  2017-07-19 14:38       ` Ismail, Mustafa
@ 2017-07-19 15:09         ` Kalderon, Michal
  0 siblings, 0 replies; 9+ messages in thread
From: Kalderon, Michal @ 2017-07-19 15:09 UTC (permalink / raw)
  To: Ismail, Mustafa, Marciniszyn, Mike, linux-rdma, dledford
  Cc: swise, linux-kernel, stable, Saleem, Shiraz, Amrani, Ram

From: Ismail, Mustafa <mustafa.ismail@intel.com>
Sent: Wednesday, July 19, 2017 5:38 PM

> > > > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > > > Cc: <stable@vger.kernel.org> # v2.6.14+
> > > > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > > > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> > >
> > Why is the second patch required if you only validate the port_num if the
> > IB_QP_PORT mask is on?
> > Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port
> > number, this one seems redundant.
> Strictly speaking it is not required, but we felt it safer to always return a valid port number
> as is done in the IB case.

It's not always initialized in the IB case either. More than that if at this point you'll
initialize it for ib as well you'll get a failure on ib_modify_qp_is_ok, since when
transitioning to RTR  / RTS providing IB_QP_PORT is not a valid option.
We actually hit this issue when running rping over RoCE. (prior to your fix i mean ) 
I agree that in general there's no real harm, but it seems a bit out of context, and if we
make the change common for ib/iwarp we'll have to modify ib_modify_qp_is_ok which 
is written close to the spec. 

thanks,
Michal

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

* Re: [PATCH v2 0/2] Fix modify_qp failure
  2017-07-14 14:41 [PATCH v2 0/2] Fix modify_qp failure Mustafa Ismail
  2017-07-14 14:41 ` [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number Mustafa Ismail
  2017-07-14 14:41 ` [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr Mustafa Ismail
@ 2017-07-22 18:17 ` Doug Ledford
  2 siblings, 0 replies; 9+ messages in thread
From: Doug Ledford @ 2017-07-22 18:17 UTC (permalink / raw)
  To: Mustafa Ismail, linux-rdma
  Cc: swise, linux-kernel, stable, e1000-rdma, shiraz.saleem


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

On 7/14/2017 10:41 AM, Mustafa Ismail wrote:
> Commit 5ecce4c9b17b("Check port number supplied by user verbs cmds") causes
> modify_qp to fail because port_num is only valid when the mask is set.
> 
> Additionally, for iWARP, the port_num is not initialized which also
> causes modify_qp to fail.
> 
> This series fixes both issues.
> 
> Changes to V2:
> * Add reviewed-by
> * Cc: <stable@vger.kernel.org>
> 
> Mustafa Ismail (2):
>   RDMA/uverbs: Fix the check for port number
>   RDMA/core: Initialize port_num in qp_attr
> 
>  drivers/infiniband/core/cma.c        | 2 ++
>  drivers/infiniband/core/uverbs_cmd.c | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 

This was accepted into 4.13-rc, thanks.

-- 
Doug Ledford <dledford@redhat.com>
    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] 9+ messages in thread

end of thread, other threads:[~2017-07-22 18:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-14 14:41 [PATCH v2 0/2] Fix modify_qp failure Mustafa Ismail
2017-07-14 14:41 ` [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number Mustafa Ismail
2017-07-17 19:10   ` Marciniszyn, Mike
2017-07-14 14:41 ` [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr Mustafa Ismail
2017-07-17 19:10   ` Marciniszyn, Mike
2017-07-19  8:09     ` Kalderon, Michal
2017-07-19 14:38       ` Ismail, Mustafa
2017-07-19 15:09         ` Kalderon, Michal
2017-07-22 18:17 ` [PATCH v2 0/2] Fix modify_qp failure Doug Ledford

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