All of lore.kernel.org
 help / color / mirror / Atom feed
* shrink struct ib_send_wr
@ 2015-08-19 16:37 Christoph Hellwig
       [not found] ` <1440002254-795-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
  0 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-19 16:37 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

This series shrinks the WR size by splitting out the different WR
types.

Patch number two is too large for the mailinglist, so if you didn't
get it grab it here:

	http://git.infradead.org/users/hch/rdma.git/commitdiff/30e522ee6c1d7adb614d7308f09fbfd71c6d3e07

or the full git tree at:

	git://git.infradead.org/users/hch/rdma.git wr-cleanup

Changes since the version sent around a couple of times:

 - new patch 1 which rejects invalid opcodes.  Patch 2 was doing
   this implicitly except for UD QPs, but I think we should a)
   do this explicitly and b) ensure this goes into 4.2 and -stable
   as I can see quite a lot of harm from submitting such malformed
   operations
 - patch 2 now covers all drivers including those in staging to
   side step any sort of discussions on the staging tree.
 - patch 2 now explicitly replaces the weird overloading in the mlx5
   driver with an explicit embedding of struct ib_send_wr, similar
   to what we do for all other MRs.
 - new patch to drop another unused send_wr field.

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

* [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 16:37 shrink struct ib_send_wr Christoph Hellwig
@ 2015-08-19 16:37     ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-19 16:37 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

We have many WR opcodes that are only supported in kernel space
and/or require optional information to be copied into the WR
structure.  Reject all those not explicitly handled so that we
can't pass invalid information to drivers.

Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index a15318a..f9f3921 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 		next->send_flags = user_wr->send_flags;
 
 		if (is_ud) {
+			if (next->opcode != IB_WR_SEND &&
+			    next->opcode != IB_WR_SEND_WITH_IMM) {
+				ret = -EINVAL;
+				goto out_put;
+			}
+
 			next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
 						     file->ucontext);
 			if (!next->wr.ud.ah) {
@@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 				next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
 				break;
 			default:
-				break;
+				ret = -EINVAL;
+				goto out_put;
 			}
 		}
 
-- 
1.9.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

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

* [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-19 16:37     ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-19 16:37 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen; +Cc: linux-rdma, stable

We have many WR opcodes that are only supported in kernel space
and/or require optional information to be copied into the WR
structure.  Reject all those not explicitly handled so that we
can't pass invalid information to drivers.

Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index a15318a..f9f3921 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 		next->send_flags = user_wr->send_flags;
 
 		if (is_ud) {
+			if (next->opcode != IB_WR_SEND &&
+			    next->opcode != IB_WR_SEND_WITH_IMM) {
+				ret = -EINVAL;
+				goto out_put;
+			}
+
 			next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
 						     file->ucontext);
 			if (!next->wr.ud.ah) {
@@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 				next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
 				break;
 			default:
-				break;
+				ret = -EINVAL;
+				goto out_put;
 			}
 		}
 
-- 
1.9.1


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

* [PATCH 3/3] IB: remove xrc_remote_srq_num from struct ib_send_wr
       [not found] ` <1440002254-795-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
  2015-08-19 16:37     ` Christoph Hellwig
@ 2015-08-19 16:37   ` Christoph Hellwig
       [not found]     ` <1440002254-795-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
  2015-08-20  9:01   ` shrink " Sagi Grimberg
  2 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-19 16:37 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

The field is only initialized in mlx, but never used.

If we want to add proper XRC support it should be done with a new
struct ib_xrc_wr.

This shrinks the various WR structures by another 4 bytes.

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 drivers/infiniband/hw/mlx5/qp.c | 1 -
 include/rdma/ib_verbs.h         | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 04df156..83a290f 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -2634,7 +2634,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 		switch (ibqp->qp_type) {
 		case IB_QPT_XRC_INI:
 			xrc = seg;
-			xrc->xrc_srqn = htonl(wr->xrc_remote_srq_num);
 			seg += sizeof(*xrc);
 			size += sizeof(*xrc) / 16;
 			/* fall through */
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 9b29c78..b855189 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1100,7 +1100,6 @@ struct ib_send_wr {
 		__be32		imm_data;
 		u32		invalidate_rkey;
 	} ex;
-	u32			xrc_remote_srq_num;	/* XRC TGT QPs only */
 };
 
 struct ib_rdma_wr {
-- 
1.9.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

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 16:37     ` Christoph Hellwig
@ 2015-08-19 17:46         ` Jason Gunthorpe
  -1 siblings, 0 replies; 30+ messages in thread
From: Jason Gunthorpe @ 2015-08-19 17:46 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 19, 2015 at 06:37:32PM +0200, Christoph Hellwig wrote:
> We have many WR opcodes that are only supported in kernel space
> and/or require optional information to be copied into the WR
> structure.  Reject all those not explicitly handled so that we
> can't pass invalid information to drivers.
> 
> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
>  drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Oh yes, this is absolutely needed for -stable.

Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

AFAIK, this path is rarely (never?) actually used. I think all the
drivers we have can post directly from userspace.

Jason
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-19 17:46         ` Jason Gunthorpe
  0 siblings, 0 replies; 30+ messages in thread
From: Jason Gunthorpe @ 2015-08-19 17:46 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen, linux-rdma, stable

On Wed, Aug 19, 2015 at 06:37:32PM +0200, Christoph Hellwig wrote:
> We have many WR opcodes that are only supported in kernel space
> and/or require optional information to be copied into the WR
> structure.  Reject all those not explicitly handled so that we
> can't pass invalid information to drivers.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>  drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Oh yes, this is absolutely needed for -stable.

Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

AFAIK, this path is rarely (never?) actually used. I think all the
drivers we have can post directly from userspace.

Jason

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 17:46         ` Jason Gunthorpe
  (?)
@ 2015-08-19 17:48         ` Christoph Hellwig
       [not found]           ` <20150819174802.GA13875-jcswGhMUV9g@public.gmane.org>
  -1 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-19 17:48 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Christoph Hellwig, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Eli Cohen, linux-rdma, stable

On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> 
> AFAIK, this path is rarely (never?) actually used. I think all the
> drivers we have can post directly from userspace.

Oh, interesting.  Is there any chance to deprecate it?  Not having
to care for the uvers command would really help with some of the
upcoming changes I have in my mind.

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

* Re: [PATCH 3/3] IB: remove xrc_remote_srq_num from struct ib_send_wr
       [not found]     ` <1440002254-795-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
@ 2015-08-19 17:48       ` Jason Gunthorpe
  2015-08-20  8:57       ` Sagi Grimberg
  1 sibling, 0 replies; 30+ messages in thread
From: Jason Gunthorpe @ 2015-08-19 17:48 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 19, 2015 at 06:37:34PM +0200, Christoph Hellwig wrote:
> The field is only initialized in mlx, but never used.
> 
> If we want to add proper XRC support it should be done with a new
> struct ib_xrc_wr.
> 
> This shrinks the various WR structures by another 4 bytes.

Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

I've never really been entirely clear on how much of this stuff needs
to be kernel side. Even the switch doesn't really make alot of sense..

> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -2634,7 +2634,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>  		switch (ibqp->qp_type) {
>  		case IB_QPT_XRC_INI:
>  			xrc = seg;
> -			xrc->xrc_srqn = htonl(wr->xrc_remote_srq_num);


Jason
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 17:48         ` Christoph Hellwig
@ 2015-08-19 17:54               ` Jason Gunthorpe
  0 siblings, 0 replies; 30+ messages in thread
From: Jason Gunthorpe @ 2015-08-19 17:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
> > Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> > 
> > AFAIK, this path is rarely (never?) actually used. I think all the
> > drivers we have can post directly from userspace.
> 
> Oh, interesting.  Is there any chance to deprecate it?  Not having
> to care for the uvers command would really help with some of the
> upcoming changes I have in my mind.

Hmm, we'd need a survey of the userspace side to see if it is rarely
or never...

And we'd have to talk to the soft XXX guys to see if they plan to use
it..

I always like to see cruft go away, especially if it is broken cruft..

Jason
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-19 17:54               ` Jason Gunthorpe
  0 siblings, 0 replies; 30+ messages in thread
From: Jason Gunthorpe @ 2015-08-19 17:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen, linux-rdma, stable

On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
> > Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> > 
> > AFAIK, this path is rarely (never?) actually used. I think all the
> > drivers we have can post directly from userspace.
> 
> Oh, interesting.  Is there any chance to deprecate it?  Not having
> to care for the uvers command would really help with some of the
> upcoming changes I have in my mind.

Hmm, we'd need a survey of the userspace side to see if it is rarely
or never...

And we'd have to talk to the soft XXX guys to see if they plan to use
it..

I always like to see cruft go away, especially if it is broken cruft..

Jason

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

* RE: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 17:46         ` Jason Gunthorpe
@ 2015-08-19 19:50             ` Hefty, Sean
  -1 siblings, 0 replies; 30+ messages in thread
From: Hefty, Sean @ 2015-08-19 19:50 UTC (permalink / raw)
  To: Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

> AFAIK, this path is rarely (never?) actually used. I think all the
> drivers we have can post directly from userspace.

I didn't think the ipath or qib drivers post from userspace.
--
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] 30+ messages in thread

* RE: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-19 19:50             ` Hefty, Sean
  0 siblings, 0 replies; 30+ messages in thread
From: Hefty, Sean @ 2015-08-19 19:50 UTC (permalink / raw)
  To: Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Hal Rosenstock, Eli Cohen, linux-rdma, stable

> AFAIK, this path is rarely (never?) actually used. I think all the
> drivers we have can post directly from userspace.

I didn't think the ipath or qib drivers post from userspace.

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 17:54               ` Jason Gunthorpe
@ 2015-08-20  8:49                   ` Sagi Grimberg
  -1 siblings, 0 replies; 30+ messages in thread
From: Sagi Grimberg @ 2015-08-20  8:49 UTC (permalink / raw)
  To: Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On 8/19/2015 8:54 PM, Jason Gunthorpe wrote:
> On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
>> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
>>> Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>>>
>>> AFAIK, this path is rarely (never?) actually used. I think all the
>>> drivers we have can post directly from userspace.
>>
>> Oh, interesting.  Is there any chance to deprecate it?  Not having
>> to care for the uvers command would really help with some of the
>> upcoming changes I have in my mind.
>
> Hmm, we'd need a survey of the userspace side to see if it is rarely
> or never...
>
> And we'd have to talk to the soft XXX guys to see if they plan to use
> it..

Checked in librxe (user-space softroce). Looks like posts are going via
this path...
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-20  8:49                   ` Sagi Grimberg
  0 siblings, 0 replies; 30+ messages in thread
From: Sagi Grimberg @ 2015-08-20  8:49 UTC (permalink / raw)
  To: Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen, linux-rdma, stable

On 8/19/2015 8:54 PM, Jason Gunthorpe wrote:
> On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
>> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
>>> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
>>>
>>> AFAIK, this path is rarely (never?) actually used. I think all the
>>> drivers we have can post directly from userspace.
>>
>> Oh, interesting.  Is there any chance to deprecate it?  Not having
>> to care for the uvers command would really help with some of the
>> upcoming changes I have in my mind.
>
> Hmm, we'd need a survey of the userspace side to see if it is rarely
> or never...
>
> And we'd have to talk to the soft XXX guys to see if they plan to use
> it..

Checked in librxe (user-space softroce). Looks like posts are going via
this path...

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 16:37     ` Christoph Hellwig
  (?)
  (?)
@ 2015-08-20  8:52     ` Sagi Grimberg
       [not found]       ` <55D59553.4080306-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  -1 siblings, 1 reply; 30+ messages in thread
From: Sagi Grimberg @ 2015-08-20  8:52 UTC (permalink / raw)
  To: Christoph Hellwig, Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma, stable

On 8/19/2015 7:37 PM, Christoph Hellwig wrote:
> We have many WR opcodes that are only supported in kernel space
> and/or require optional information to be copied into the WR
> structure.  Reject all those not explicitly handled so that we
> can't pass invalid information to drivers.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index a15318a..f9f3921 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>   		next->send_flags = user_wr->send_flags;
>
>   		if (is_ud) {
> +			if (next->opcode != IB_WR_SEND &&
> +			    next->opcode != IB_WR_SEND_WITH_IMM) {
> +				ret = -EINVAL;
> +				goto out_put;
> +			}
> +
>   			next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
>   						     file->ucontext);
>   			if (!next->wr.ud.ah) {
> @@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>   				next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
>   				break;
>   			default:
> -				break;
> +				ret = -EINVAL;
> +				goto out_put;
>   			}
>   		}
>
>

Reviewed-by: Sagi Grimberg <sagig@mellanox.com>

Haggai, can you also have a look?

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

* Re: [PATCH 3/3] IB: remove xrc_remote_srq_num from struct ib_send_wr
       [not found]     ` <1440002254-795-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
  2015-08-19 17:48       ` Jason Gunthorpe
@ 2015-08-20  8:57       ` Sagi Grimberg
  1 sibling, 0 replies; 30+ messages in thread
From: Sagi Grimberg @ 2015-08-20  8:57 UTC (permalink / raw)
  To: Christoph Hellwig, Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On 8/19/2015 7:37 PM, Christoph Hellwig wrote:
> The field is only initialized in mlx, but never used.
>
> If we want to add proper XRC support it should be done with a new
> struct ib_xrc_wr.
>
> This shrinks the various WR structures by another 4 bytes.
>
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---
>   drivers/infiniband/hw/mlx5/qp.c | 1 -
>   include/rdma/ib_verbs.h         | 1 -
>   2 files changed, 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 04df156..83a290f 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -2634,7 +2634,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
>   		switch (ibqp->qp_type) {
>   		case IB_QPT_XRC_INI:
>   			xrc = seg;
> -			xrc->xrc_srqn = htonl(wr->xrc_remote_srq_num);
>   			seg += sizeof(*xrc);
>   			size += sizeof(*xrc) / 16;
>   			/* fall through */
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 9b29c78..b855189 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1100,7 +1100,6 @@ struct ib_send_wr {
>   		__be32		imm_data;
>   		u32		invalidate_rkey;
>   	} ex;
> -	u32			xrc_remote_srq_num;	/* XRC TGT QPs only */
>   };
>
>   struct ib_rdma_wr {
>

Looks OK to me,

Reviewed-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

This will need Eli's ack though...
--
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] 30+ messages in thread

* Re: shrink struct ib_send_wr
       [not found] ` <1440002254-795-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
  2015-08-19 16:37     ` Christoph Hellwig
  2015-08-19 16:37   ` [PATCH 3/3] IB: remove xrc_remote_srq_num from struct ib_send_wr Christoph Hellwig
@ 2015-08-20  9:01   ` Sagi Grimberg
  2 siblings, 0 replies; 30+ messages in thread
From: Sagi Grimberg @ 2015-08-20  9:01 UTC (permalink / raw)
  To: Christoph Hellwig, Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Haggai Eran

>   - patch 2 now explicitly replaces the weird overloading in the mlx5
>     driver with an explicit embedding of struct ib_send_wr, similar
>     to what we do for all other MRs.

This is on the user-space memory registration path.

Haggai, can you grab it for a Tested-by tag?
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-19 19:50             ` Hefty, Sean
  (?)
@ 2015-08-20  9:22             ` Christoph Hellwig
  -1 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-20  9:22 UTC (permalink / raw)
  To: Hefty, Sean
  Cc: Jason Gunthorpe, Christoph Hellwig, Doug Ledford, Hal Rosenstock,
	Eli Cohen, linux-rdma, stable

On Wed, Aug 19, 2015 at 07:50:23PM +0000, Hefty, Sean wrote:
> > AFAIK, this path is rarely (never?) actually used. I think all the
> > drivers we have can post directly from userspace.
> 
> I didn't think the ipath or qib drivers post from userspace.

Makes sense with their software IB stack.  Guess the idea to get rid
of this path is dead, would have been too nice..

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-20  8:49                   ` Sagi Grimberg
@ 2015-08-20 22:30                       ` Steve Wise
  -1 siblings, 0 replies; 30+ messages in thread
From: Steve Wise @ 2015-08-20 22:30 UTC (permalink / raw)
  To: Sagi Grimberg, Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On 8/20/2015 3:49 AM, Sagi Grimberg wrote:
> On 8/19/2015 8:54 PM, Jason Gunthorpe wrote:
>> On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
>>> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
>>>> Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>>>>
>>>> AFAIK, this path is rarely (never?) actually used. I think all the
>>>> drivers we have can post directly from userspace.
>>>
>>> Oh, interesting.  Is there any chance to deprecate it?  Not having
>>> to care for the uvers command would really help with some of the
>>> upcoming changes I have in my mind.
>>
>> Hmm, we'd need a survey of the userspace side to see if it is rarely
>> or never...
>>
>> And we'd have to talk to the soft XXX guys to see if they plan to use
>> it..
>
> Checked in librxe (user-space softroce). Looks like posts are going via
> this path...

Ditto for the soft iWARP stack, which is still out-of-linux.


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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-20 22:30                       ` Steve Wise
  0 siblings, 0 replies; 30+ messages in thread
From: Steve Wise @ 2015-08-20 22:30 UTC (permalink / raw)
  To: Sagi Grimberg, Jason Gunthorpe, Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Eli Cohen, linux-rdma, stable

On 8/20/2015 3:49 AM, Sagi Grimberg wrote:
> On 8/19/2015 8:54 PM, Jason Gunthorpe wrote:
>> On Wed, Aug 19, 2015 at 07:48:02PM +0200, Christoph Hellwig wrote:
>>> On Wed, Aug 19, 2015 at 11:46:14AM -0600, Jason Gunthorpe wrote:
>>>> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
>>>>
>>>> AFAIK, this path is rarely (never?) actually used. I think all the
>>>> drivers we have can post directly from userspace.
>>>
>>> Oh, interesting.  Is there any chance to deprecate it?  Not having
>>> to care for the uvers command would really help with some of the
>>> upcoming changes I have in my mind.
>>
>> Hmm, we'd need a survey of the userspace side to see if it is rarely
>> or never...
>>
>> And we'd have to talk to the soft XXX guys to see if they plan to use
>> it..
>
> Checked in librxe (user-space softroce). Looks like posts are going via
> this path...

Ditto for the soft iWARP stack, which is still out-of-linux.



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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-20  8:52     ` Sagi Grimberg
@ 2015-08-22  6:38           ` Haggai Eran
  0 siblings, 0 replies; 30+ messages in thread
From: Haggai Eran @ 2015-08-22  6:38 UTC (permalink / raw)
  To: Sagi Grimberg, Christoph Hellwig, Doug Ledford, Sean Hefty,
	Hal Rosenstock, Eli Cohen
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA

On Thursday, August 20, 2015 11:52 AM, linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org <linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> on behalf of Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org> wrote:
> On 8/19/2015 7:37 PM, Christoph Hellwig wrote:
>> We have many WR opcodes that are only supported in kernel space
>> and/or require optional information to be copied into the WR
>> structure.  Reject all those not explicitly handled so that we
>> can't pass invalid information to drivers.
>>
>> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
>> ---
>>   drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
>> index a15318a..f9f3921 100644
>> --- a/drivers/infiniband/core/uverbs_cmd.c
>> +++ b/drivers/infiniband/core/uverbs_cmd.c
>> @@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>>               next->send_flags = user_wr->send_flags;
>>
>>               if (is_ud) {
>> +                     if (next->opcode != IB_WR_SEND &&
>> +                         next->opcode != IB_WR_SEND_WITH_IMM) {
>> +                             ret = -EINVAL;
>> +                             goto out_put;
>> +                     }
>> +
>>                       next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
>>                                                    file->ucontext);
>>                       if (!next->wr.ud.ah) {
>> @@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>>                               next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
>>                               break;
>>                       default:
>> -                             break;
>> +                             ret = -EINVAL;
>> +                             goto out_put;
>>                       }
>>               }
>>
>>
> 
> Reviewed-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> 
> Haggai, can you also have a look?

It looks like the default case in the non-UD branch is currently used to handle plain IB_WR_SEND operations, so the patch would cause these to return an error.

Haggai--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-22  6:38           ` Haggai Eran
  0 siblings, 0 replies; 30+ messages in thread
From: Haggai Eran @ 2015-08-22  6:38 UTC (permalink / raw)
  To: Sagi Grimberg, Christoph Hellwig, Doug Ledford, Sean Hefty,
	Hal Rosenstock, Eli Cohen
  Cc: linux-rdma, stable

On Thursday, August 20, 2015 11:52 AM, linux-rdma-owner@vger.kernel.org <linux-rdma-owner@vger.kernel.org> on behalf of Sagi Grimberg <sagig@dev.mellanox.co.il> wrote:
> On 8/19/2015 7:37 PM, Christoph Hellwig wrote:
>> We have many WR opcodes that are only supported in kernel space
>> and/or require optional information to be copied into the WR
>> structure.  Reject all those not explicitly handled so that we
>> can't pass invalid information to drivers.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> ---
>>   drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
>> index a15318a..f9f3921 100644
>> --- a/drivers/infiniband/core/uverbs_cmd.c
>> +++ b/drivers/infiniband/core/uverbs_cmd.c
>> @@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>>               next->send_flags = user_wr->send_flags;
>>
>>               if (is_ud) {
>> +                     if (next->opcode != IB_WR_SEND &&
>> +                         next->opcode != IB_WR_SEND_WITH_IMM) {
>> +                             ret = -EINVAL;
>> +                             goto out_put;
>> +                     }
>> +
>>                       next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
>>                                                    file->ucontext);
>>                       if (!next->wr.ud.ah) {
>> @@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
>>                               next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
>>                               break;
>>                       default:
>> -                             break;
>> +                             ret = -EINVAL;
>> +                             goto out_put;
>>                       }
>>               }
>>
>>
> 
> Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
> 
> Haggai, can you also have a look?

It looks like the default case in the non-UD branch is currently used to handle plain IB_WR_SEND operations, so the patch would cause these to return an error.

Haggai

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-22  6:38           ` Haggai Eran
  (?)
@ 2015-08-22  8:25           ` Christoph Hellwig
  2015-08-24  6:52             ` Haggai Eran
  -1 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-22  8:25 UTC (permalink / raw)
  To: Haggai Eran
  Cc: Sagi Grimberg, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Eli Cohen, linux-rdma, stable

On Sat, Aug 22, 2015 at 06:38:47AM +0000, Haggai Eran wrote:
> It looks like the default case in the non-UD branch is currently used to handle plain IB_WR_SEND operations, so the patch would cause these to return an error.

Indeed.  It's handled fine in patch 2 which splits up the case, but
will be incorrectly rejected with just this patch applied.

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-22  8:25           ` Christoph Hellwig
@ 2015-08-24  6:52             ` Haggai Eran
       [not found]               ` <55DABF1E.2050804-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 30+ messages in thread
From: Haggai Eran @ 2015-08-24  6:52 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Eli Cohen, linux-rdma, stable

On 22/08/2015 11:25, Christoph Hellwig wrote:
> On Sat, Aug 22, 2015 at 06:38:47AM +0000, Haggai Eran wrote:
>> It looks like the default case in the non-UD branch is currently used to handle plain IB_WR_SEND operations, so the patch would cause these to return an error.
> 
> Indeed.  It's handled fine in patch 2 which splits up the case, but
> will be incorrectly rejected with just this patch applied.

Okay. Maybe you can just add a case for IB_WR_SEND in this patch to
avoid hurting bisectability.

Looking at the uverbs part in patch 2, I think the changes are okay. I
noticed there's a (__be32 __force) cast of the immediate data from
userspace (it was already in the existing code). I wonder, why not
define the field in the uapi struct as __be32 in the first place?

Haggai

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-24  6:52             ` Haggai Eran
@ 2015-08-24  6:55                   ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-24  6:55 UTC (permalink / raw)
  To: Haggai Eran
  Cc: Christoph Hellwig, Sagi Grimberg, Doug Ledford, Sean Hefty,
	Hal Rosenstock, Eli Cohen, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	stable-u79uwXL29TY76Z2rM5mHXA

On Mon, Aug 24, 2015 at 09:52:14AM +0300, Haggai Eran wrote:
> Okay. Maybe you can just add a case for IB_WR_SEND in this patch to
> avoid hurting bisectability.

I've done this already, just waiting for more feedback before resending:

http://git.infradead.org/users/hch/rdma.git/commitdiff/20f34ca8ecac302984f3a92b9ad29f5f4b41780d

> Looking at the uverbs part in patch 2, I think the changes are okay. I
> noticed there's a (__be32 __force) cast of the immediate data from
> userspace (it was already in the existing code). I wonder, why not
> define the field in the uapi struct as __be32 in the first place?

It looks odd to me as well, but it's not really something I want to
change in this series.  Note that sparse annoted types like __be32
aren't really common in userspace, but with a bit of effort they can
be supported.  We have them and regularly run sparse for xfsprogs for
example.
--
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] 30+ messages in thread

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-24  6:55                   ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-24  6:55 UTC (permalink / raw)
  To: Haggai Eran
  Cc: Christoph Hellwig, Sagi Grimberg, Doug Ledford, Sean Hefty,
	Hal Rosenstock, Eli Cohen, linux-rdma, stable

On Mon, Aug 24, 2015 at 09:52:14AM +0300, Haggai Eran wrote:
> Okay. Maybe you can just add a case for IB_WR_SEND in this patch to
> avoid hurting bisectability.

I've done this already, just waiting for more feedback before resending:

http://git.infradead.org/users/hch/rdma.git/commitdiff/20f34ca8ecac302984f3a92b9ad29f5f4b41780d

> Looking at the uverbs part in patch 2, I think the changes are okay. I
> noticed there's a (__be32 __force) cast of the immediate data from
> userspace (it was already in the existing code). I wonder, why not
> define the field in the uapi struct as __be32 in the first place?

It looks odd to me as well, but it's not really something I want to
change in this series.  Note that sparse annoted types like __be32
aren't really common in userspace, but with a bit of effort they can
be supported.  We have them and regularly run sparse for xfsprogs for
example.

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-24  6:55                   ` Christoph Hellwig
@ 2015-08-24  7:59                       ` Haggai Eran
  -1 siblings, 0 replies; 30+ messages in thread
From: Haggai Eran @ 2015-08-24  7:59 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Eli Cohen, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	stable-u79uwXL29TY76Z2rM5mHXA

On 24/08/2015 09:55, Christoph Hellwig wrote:
> On Mon, Aug 24, 2015 at 09:52:14AM +0300, Haggai Eran wrote:
>> Okay. Maybe you can just add a case for IB_WR_SEND in this patch to
>> avoid hurting bisectability.
> 
> I've done this already, just waiting for more feedback before resending:
> 
> http://git.infradead.org/users/hch/rdma.git/commitdiff/20f34ca8ecac302984f3a92b9ad29f5f4b41780d

Great.

>> Looking at the uverbs part in patch 2, I think the changes are okay. I
>> noticed there's a (__be32 __force) cast of the immediate data from
>> userspace (it was already in the existing code). I wonder, why not
>> define the field in the uapi struct as __be32 in the first place?
> 
> It looks odd to me as well, but it's not really something I want to
> change in this series.  Note that sparse annoted types like __be32
> aren't really common in userspace, but with a bit of effort they can
> be supported.  We have them and regularly run sparse for xfsprogs for
> example.

I have to try it with libibverbs sometime. It doesn't use uapi yet
though IIRC - it has its own version of the header files.

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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
@ 2015-08-24  7:59                       ` Haggai Eran
  0 siblings, 0 replies; 30+ messages in thread
From: Haggai Eran @ 2015-08-24  7:59 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Eli Cohen, linux-rdma, stable

On 24/08/2015 09:55, Christoph Hellwig wrote:
> On Mon, Aug 24, 2015 at 09:52:14AM +0300, Haggai Eran wrote:
>> Okay. Maybe you can just add a case for IB_WR_SEND in this patch to
>> avoid hurting bisectability.
> 
> I've done this already, just waiting for more feedback before resending:
> 
> http://git.infradead.org/users/hch/rdma.git/commitdiff/20f34ca8ecac302984f3a92b9ad29f5f4b41780d

Great.

>> Looking at the uverbs part in patch 2, I think the changes are okay. I
>> noticed there's a (__be32 __force) cast of the immediate data from
>> userspace (it was already in the existing code). I wonder, why not
>> define the field in the uapi struct as __be32 in the first place?
> 
> It looks odd to me as well, but it's not really something I want to
> change in this series.  Note that sparse annoted types like __be32
> aren't really common in userspace, but with a bit of effort they can
> be supported.  We have them and regularly run sparse for xfsprogs for
> example.

I have to try it with libibverbs sometime. It doesn't use uapi yet
though IIRC - it has its own version of the header files.


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

* Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-24  7:59                       ` Haggai Eran
  (?)
@ 2015-08-25  8:55                       ` Christoph Hellwig
  -1 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-25  8:55 UTC (permalink / raw)
  To: Haggai Eran
  Cc: Christoph Hellwig, Sagi Grimberg, Doug Ledford, Sean Hefty,
	Hal Rosenstock, Eli Cohen, linux-rdma, stable

On Mon, Aug 24, 2015 at 10:59:21AM +0300, Haggai Eran wrote:
> > It looks odd to me as well, but it's not really something I want to
> > change in this series.  Note that sparse annoted types like __be32
> > aren't really common in userspace, but with a bit of effort they can
> > be supported.  We have them and regularly run sparse for xfsprogs for
> > example.
> 
> I have to try it with libibverbs sometime. It doesn't use uapi yet
> though IIRC - it has its own version of the header files.

Yes, I noticed that.  And the WR opcodes aren't even exported in the
uapi header, and use a shared namespace with the in-kernel only ones.

It's all a giant mess unfortunately.

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

* [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes
  2015-08-26  9:00 shrink struct ib_send_wr V3 Christoph Hellwig
@ 2015-08-26  9:00 ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2015-08-26  9:00 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Eli Cohen; +Cc: linux-rdma, stable

We have many WR opcodes that are only supported in kernel space
and/or require optional information to be copied into the WR
structure.  Reject all those not explicitly handled so that we
can't pass invalid information to drivers.

Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/infiniband/core/uverbs_cmd.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index a15318a..be4cb9f 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 		next->send_flags = user_wr->send_flags;
 
 		if (is_ud) {
+			if (next->opcode != IB_WR_SEND &&
+			    next->opcode != IB_WR_SEND_WITH_IMM) {
+				ret = -EINVAL;
+				goto out_put;
+			}
+
 			next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
 						     file->ucontext);
 			if (!next->wr.ud.ah) {
@@ -2411,9 +2417,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 					user_wr->wr.atomic.compare_add;
 				next->wr.atomic.swap = user_wr->wr.atomic.swap;
 				next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
+			case IB_WR_SEND:
 				break;
 			default:
-				break;
+				ret = -EINVAL;
+				goto out_put;
 			}
 		}
 
-- 
1.9.1

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

end of thread, other threads:[~2015-08-26  9:00 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-19 16:37 shrink struct ib_send_wr Christoph Hellwig
     [not found] ` <1440002254-795-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-08-19 16:37   ` [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes Christoph Hellwig
2015-08-19 16:37     ` Christoph Hellwig
     [not found]     ` <1440002254-795-2-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-08-19 17:46       ` Jason Gunthorpe
2015-08-19 17:46         ` Jason Gunthorpe
2015-08-19 17:48         ` Christoph Hellwig
     [not found]           ` <20150819174802.GA13875-jcswGhMUV9g@public.gmane.org>
2015-08-19 17:54             ` Jason Gunthorpe
2015-08-19 17:54               ` Jason Gunthorpe
     [not found]               ` <20150819175425.GE22646-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-20  8:49                 ` Sagi Grimberg
2015-08-20  8:49                   ` Sagi Grimberg
     [not found]                   ` <55D594B3.7090807-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-20 22:30                     ` Steve Wise
2015-08-20 22:30                       ` Steve Wise
     [not found]         ` <20150819174614.GC22646-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-19 19:50           ` Hefty, Sean
2015-08-19 19:50             ` Hefty, Sean
2015-08-20  9:22             ` Christoph Hellwig
2015-08-20  8:52     ` Sagi Grimberg
     [not found]       ` <55D59553.4080306-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-08-22  6:38         ` Haggai Eran
2015-08-22  6:38           ` Haggai Eran
2015-08-22  8:25           ` Christoph Hellwig
2015-08-24  6:52             ` Haggai Eran
     [not found]               ` <55DABF1E.2050804-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-08-24  6:55                 ` Christoph Hellwig
2015-08-24  6:55                   ` Christoph Hellwig
     [not found]                   ` <20150824065501.GA31990-jcswGhMUV9g@public.gmane.org>
2015-08-24  7:59                     ` Haggai Eran
2015-08-24  7:59                       ` Haggai Eran
2015-08-25  8:55                       ` Christoph Hellwig
2015-08-19 16:37   ` [PATCH 3/3] IB: remove xrc_remote_srq_num from struct ib_send_wr Christoph Hellwig
     [not found]     ` <1440002254-795-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-08-19 17:48       ` Jason Gunthorpe
2015-08-20  8:57       ` Sagi Grimberg
2015-08-20  9:01   ` shrink " Sagi Grimberg
2015-08-26  9:00 shrink struct ib_send_wr V3 Christoph Hellwig
2015-08-26  9:00 ` [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes Christoph Hellwig

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.