All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-07-26 16:14 Mustafa Ismail
       [not found] ` <1501085686-12916-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Mustafa Ismail @ 2017-07-26 16:14 UTC (permalink / raw)
  To: linux-rdma
  Cc: mustafa.ismail, e1000-rdma, chien.tin.tung, shiraz.saleem,
	# v4 . 2-v4 . 9, security, Doug Ledford, Steve Wise,
	Mike Marciniszyn

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> # v4.2-v4.9
Cc: <security@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Steve Wise <swise@opengridcomputing.com>
Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Upstream commit 5a7a88f1b488("Fix the check for port number")
Modified from upstream commit: helper function rdma_is_port_valid does not
exist in these kernel versions.
---
 drivers/infiniband/core/uverbs_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 01e3a37..d118ffe 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	if (cmd.port_num < rdma_start_port(ib_dev) ||
-	    cmd.port_num > rdma_end_port(ib_dev))
+	if ((cmd.attr_mask & IB_QP_PORT) &&
+	    (cmd.port_num < rdma_start_port(ib_dev) ||
+	     cmd.port_num > rdma_end_port(ib_dev)))
 		return -EINVAL;
 
 	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
-- 
1.8.3.1

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

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
  2017-07-26 16:14 [PATCH] RDMA/uverbs: Fix the check for port number Mustafa Ismail
@ 2017-08-03 22:41     ` Greg KH
  0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2017-08-03 22:41 UTC (permalink / raw)
  To: Mustafa Ismail
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	chien.tin.tung-ral2JQCrhuEAvxtiuMwx3w,
	shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w, # v4 . 2-v4 . 9,
	security-DgEjT+Ai2ygdnm+yROfE0A, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v4.2-v4.9
> Cc: <security-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> Cc: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Signed-off-by: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Upstream commit 5a7a88f1b488("Fix the check for port number")
> Modified from upstream commit: helper function rdma_is_port_valid does not
> exist in these kernel versions.

Note, you sent this 3 times for some reason, why?

Also, it was hard to figure out what to do with it, I think it was ment
for me to apply to the 4.4 and 4.9-stable trees, right?  If so, I've
done that, if not, please let me know.

thanks,

greg k-h
--
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] 11+ messages in thread

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-08-03 22:41     ` Greg KH
  0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2017-08-03 22:41 UTC (permalink / raw)
  To: Mustafa Ismail
  Cc: linux-rdma, e1000-rdma, chien.tin.tung, shiraz.saleem,
	# v4 . 2-v4 . 9, security, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> 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> # v4.2-v4.9
> Cc: <security@kernel.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: Steve Wise <swise@opengridcomputing.com>
> Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> 
> Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> 
> Upstream commit 5a7a88f1b488("Fix the check for port number")
> Modified from upstream commit: helper function rdma_is_port_valid does not
> exist in these kernel versions.

Note, you sent this 3 times for some reason, why?

Also, it was hard to figure out what to do with it, I think it was ment
for me to apply to the 4.4 and 4.9-stable trees, right?  If so, I've
done that, if not, please let me know.

thanks,

greg k-h

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

* RE: [PATCH] RDMA/uverbs: Fix the check for port number
  2017-08-03 22:41     ` Greg KH
@ 2017-08-03 23:34         ` Saleem, Shiraz
  -1 siblings, 0 replies; 11+ messages in thread
From: Saleem, Shiraz @ 2017-08-03 23:34 UTC (permalink / raw)
  To: Greg KH, Ismail, Mustafa
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Tung, Chien Tin,
	# v4 . 2-v4 . 9, security-DgEjT+Ai2ygdnm+yROfE0A, Doug Ledford,
	Steve Wise, Marciniszyn, Mike

> Subject: Re: [PATCH] RDMA/uverbs: Fix the check for port number
> 
> On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> > 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v4.2-v4.9
> > Cc: <security-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> > Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> > Cc: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> >
> > Signed-off-by: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> >
> > Upstream commit 5a7a88f1b488("Fix the check for port number") Modified
> > from upstream commit: helper function rdma_is_port_valid does not
> > exist in these kernel versions.
> 
> Note, you sent this 3 times for some reason, why?
> 
> Also, it was hard to figure out what to do with it, I think it was ment for me to apply
> to the 4.4 and 4.9-stable trees, right?  If so, I've done that, if not, please let me
> know.
> 

Hi Greg - Mustafa is on vacation. Yes. The patch is meant for 4.4 and 4.9 stable tree.

Shiraz
--
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] 11+ messages in thread

* RE: [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-08-03 23:34         ` Saleem, Shiraz
  0 siblings, 0 replies; 11+ messages in thread
From: Saleem, Shiraz @ 2017-08-03 23:34 UTC (permalink / raw)
  To: Greg KH, Ismail, Mustafa
  Cc: linux-rdma, e1000-rdma, Tung, Chien Tin, # v4 . 2-v4 . 9,
	security, Doug Ledford, Steve Wise, Marciniszyn, Mike

> Subject: Re: [PATCH] RDMA/uverbs: Fix the check for port number
> 
> On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> > 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> # v4.2-v4.9
> > Cc: <security@kernel.org>
> > Cc: Doug Ledford <dledford@redhat.com>
> > Cc: Steve Wise <swise@opengridcomputing.com>
> > Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> >
> > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> >
> > Upstream commit 5a7a88f1b488("Fix the check for port number") Modified
> > from upstream commit: helper function rdma_is_port_valid does not
> > exist in these kernel versions.
> 
> Note, you sent this 3 times for some reason, why?
> 
> Also, it was hard to figure out what to do with it, I think it was ment for me to apply
> to the 4.4 and 4.9-stable trees, right?  If so, I've done that, if not, please let me
> know.
> 

Hi Greg - Mustafa is on vacation. Yes. The patch is meant for 4.4 and 4.9 stable tree.

Shiraz

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

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
  2017-07-26 16:14 [PATCH] RDMA/uverbs: Fix the check for port number Mustafa Ismail
@ 2017-08-07 11:03     ` Yuval Shaia
  0 siblings, 0 replies; 11+ messages in thread
From: Yuval Shaia @ 2017-08-07 11:03 UTC (permalink / raw)
  To: Mustafa Ismail
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	chien.tin.tung-ral2JQCrhuEAvxtiuMwx3w,
	shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w, # v4 . 2-v4 . 9,
	security-DgEjT+Ai2ygdnm+yROfE0A, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v4.2-v4.9
> Cc: <security-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> Cc: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Signed-off-by: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Upstream commit 5a7a88f1b488("Fix the check for port number")
> Modified from upstream commit: helper function rdma_is_port_valid does not
> exist in these kernel versions.
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 01e3a37..d118ffe 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
>  	if (copy_from_user(&cmd, buf, sizeof cmd))
>  		return -EFAULT;
>  
> -	if (cmd.port_num < rdma_start_port(ib_dev) ||
> -	    cmd.port_num > rdma_end_port(ib_dev))
> +	if ((cmd.attr_mask & IB_QP_PORT) &&
> +	    (cmd.port_num < rdma_start_port(ib_dev) ||
> +	     cmd.port_num > rdma_end_port(ib_dev)))

Please use rdma_is_port_valid

>  		return -EINVAL;
>  
>  	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
> -- 
> 1.8.3.1
> 
> --
> 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] 11+ messages in thread

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-08-07 11:03     ` Yuval Shaia
  0 siblings, 0 replies; 11+ messages in thread
From: Yuval Shaia @ 2017-08-07 11:03 UTC (permalink / raw)
  To: Mustafa Ismail
  Cc: linux-rdma, e1000-rdma, chien.tin.tung, shiraz.saleem,
	# v4 . 2-v4 . 9, security, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> 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> # v4.2-v4.9
> Cc: <security@kernel.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: Steve Wise <swise@opengridcomputing.com>
> Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> 
> Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> 
> Upstream commit 5a7a88f1b488("Fix the check for port number")
> Modified from upstream commit: helper function rdma_is_port_valid does not
> exist in these kernel versions.
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 01e3a37..d118ffe 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
>  	if (copy_from_user(&cmd, buf, sizeof cmd))
>  		return -EFAULT;
>  
> -	if (cmd.port_num < rdma_start_port(ib_dev) ||
> -	    cmd.port_num > rdma_end_port(ib_dev))
> +	if ((cmd.attr_mask & IB_QP_PORT) &&
> +	    (cmd.port_num < rdma_start_port(ib_dev) ||
> +	     cmd.port_num > rdma_end_port(ib_dev)))

Please use rdma_is_port_valid

>  		return -EINVAL;
>  
>  	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
  2017-08-07 11:03     ` Yuval Shaia
@ 2017-08-07 12:11       ` Chien Tin Tung
  -1 siblings, 0 replies; 11+ messages in thread
From: Chien Tin Tung @ 2017-08-07 12:11 UTC (permalink / raw)
  To: Yuval Shaia
  Cc: Mustafa Ismail, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w, # v4 . 2-v4 . 9,
	security-DgEjT+Ai2ygdnm+yROfE0A, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Mon, Aug 07, 2017 at 02:03:08PM +0300, Yuval Shaia wrote:
> On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> > 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v4.2-v4.9
> > Cc: <security-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> > Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> > Cc: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > 
> > Signed-off-by: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > 
> > Upstream commit 5a7a88f1b488("Fix the check for port number")
> > Modified from upstream commit: helper function rdma_is_port_valid does not
> > exist in these kernel versions.
> > ---
> >  drivers/infiniband/core/uverbs_cmd.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> > index 01e3a37..d118ffe 100644
> > --- a/drivers/infiniband/core/uverbs_cmd.c
> > +++ b/drivers/infiniband/core/uverbs_cmd.c
> > @@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
> >  	if (copy_from_user(&cmd, buf, sizeof cmd))
> >  		return -EFAULT;
> >  
> > -	if (cmd.port_num < rdma_start_port(ib_dev) ||
> > -	    cmd.port_num > rdma_end_port(ib_dev))
> > +	if ((cmd.attr_mask & IB_QP_PORT) &&
> > +	    (cmd.port_num < rdma_start_port(ib_dev) ||
> > +	     cmd.port_num > rdma_end_port(ib_dev)))
> 
> Please use rdma_is_port_valid

Yuval,

This patch is meant for Stable v4.2-v4.9 which does not have
rdma_is_port_valid.  The patch upstream is using rdma_is_port_valid.
Here is a link to it: https://patchwork.kernel.org/patch/9841243/

Chien
--
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] 11+ messages in thread

* Re: [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-08-07 12:11       ` Chien Tin Tung
  0 siblings, 0 replies; 11+ messages in thread
From: Chien Tin Tung @ 2017-08-07 12:11 UTC (permalink / raw)
  To: Yuval Shaia
  Cc: Mustafa Ismail, linux-rdma, e1000-rdma, shiraz.saleem,
	# v4 . 2-v4 . 9, security, Doug Ledford, Steve Wise,
	Mike Marciniszyn

On Mon, Aug 07, 2017 at 02:03:08PM +0300, Yuval Shaia wrote:
> On Wed, Jul 26, 2017 at 11:14:46AM -0500, Mustafa Ismail wrote:
> > 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> # v4.2-v4.9
> > Cc: <security@kernel.org>
> > Cc: Doug Ledford <dledford@redhat.com>
> > Cc: Steve Wise <swise@opengridcomputing.com>
> > Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> > 
> > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> > 
> > Upstream commit 5a7a88f1b488("Fix the check for port number")
> > Modified from upstream commit: helper function rdma_is_port_valid does not
> > exist in these kernel versions.
> > ---
> >  drivers/infiniband/core/uverbs_cmd.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> > index 01e3a37..d118ffe 100644
> > --- a/drivers/infiniband/core/uverbs_cmd.c
> > +++ b/drivers/infiniband/core/uverbs_cmd.c
> > @@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
> >  	if (copy_from_user(&cmd, buf, sizeof cmd))
> >  		return -EFAULT;
> >  
> > -	if (cmd.port_num < rdma_start_port(ib_dev) ||
> > -	    cmd.port_num > rdma_end_port(ib_dev))
> > +	if ((cmd.attr_mask & IB_QP_PORT) &&
> > +	    (cmd.port_num < rdma_start_port(ib_dev) ||
> > +	     cmd.port_num > rdma_end_port(ib_dev)))
> 
> Please use rdma_is_port_valid

Yuval,

This patch is meant for Stable v4.2-v4.9 which does not have
rdma_is_port_valid.  The patch upstream is using rdma_is_port_valid.
Here is a link to it: https://patchwork.kernel.org/patch/9841243/

Chien

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

* [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-07-26 15:18 Mustafa Ismail
  0 siblings, 0 replies; 11+ messages in thread
From: Mustafa Ismail @ 2017-07-26 15:18 UTC (permalink / raw)
  To: mustafa.ismail
  Cc: chien.tin.tung, tatyana.e.nikolova, henry.orosco, sindhu.devale,
	# v4 . 2-v4 . 9, security

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> # v4.2-v4.9
Cc: <security@kernel.org>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Upstream commit 5a7a88f1b488("Fix the check for port number")
Modified from upstream commit: helper function rdma_is_port_valid does not
exist in these kernel versions.
---
 drivers/infiniband/core/uverbs_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 01e3a37..d118ffe 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	if (cmd.port_num < rdma_start_port(ib_dev) ||
-	    cmd.port_num > rdma_end_port(ib_dev))
+	if ((cmd.attr_mask & IB_QP_PORT) &&
+	    (cmd.port_num < rdma_start_port(ib_dev) ||
+	     cmd.port_num > rdma_end_port(ib_dev)))
 		return -EINVAL;
 
 	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
-- 
1.8.3.1

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

* [PATCH] RDMA/uverbs: Fix the check for port number
@ 2017-07-26 15:14 Mustafa Ismail
  0 siblings, 0 replies; 11+ messages in thread
From: Mustafa Ismail @ 2017-07-26 15:14 UTC (permalink / raw)
  To: mustafa.ismail; +Cc: # v4 . 2-v4 . 9, security

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> # v4.2-v4.9
Cc: <security@kernel.org>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Upstream commit 5a7a88f1b488("Fix the check for port number")
Modified from upstream commit: helper function rdma_is_port_valid does not
exist in these kernel versions.
---
 drivers/infiniband/core/uverbs_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 01e3a37..d118ffe 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2342,8 +2342,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
-	if (cmd.port_num < rdma_start_port(ib_dev) ||
-	    cmd.port_num > rdma_end_port(ib_dev))
+	if ((cmd.attr_mask & IB_QP_PORT) &&
+	    (cmd.port_num < rdma_start_port(ib_dev) ||
+	     cmd.port_num > rdma_end_port(ib_dev)))
 		return -EINVAL;
 
 	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
-- 
1.8.3.1

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

end of thread, other threads:[~2017-08-07 12:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-26 16:14 [PATCH] RDMA/uverbs: Fix the check for port number Mustafa Ismail
     [not found] ` <1501085686-12916-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-03 22:41   ` Greg KH
2017-08-03 22:41     ` Greg KH
     [not found]     ` <20170803224149.GF2396-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-08-03 23:34       ` Saleem, Shiraz
2017-08-03 23:34         ` Saleem, Shiraz
2017-08-07 11:03   ` Yuval Shaia
2017-08-07 11:03     ` Yuval Shaia
2017-08-07 12:11     ` Chien Tin Tung
2017-08-07 12:11       ` Chien Tin Tung
  -- strict thread matches above, loose matches on Subject: below --
2017-07-26 15:18 Mustafa Ismail
2017-07-26 15:14 Mustafa Ismail

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.