diff mbox series

[for-next] IB/hfi1: Error path MAD response size is incorrect

Message ID 20180928143452.11727.81430.stgit@scvm10.sc.intel.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [for-next] IB/hfi1: Error path MAD response size is incorrect | expand

Commit Message

Dennis Dalessandro Sept. 28, 2018, 2:34 p.m. UTC
From: Michael J. Ruhl <michael.j.ruhl@intel.com>

If a MAD packet has incorrect header information, the logic uses the
reply path to report the error.  The reply path expects *resp_len to
be set prior to return.  Unfortunately, *resp_len is set to 0 for this
path.  This causes an incorrect response packet.

Fix by ensuring that the *resp_len is defaulted to the incoming packet
size (wc->bytes_len - sizeof(GRH)).

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/hw/hfi1/mad.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jason Gunthorpe Sept. 28, 2018, 4:14 p.m. UTC | #1
On Fri, Sep 28, 2018 at 07:34:57AM -0700, Dennis Dalessandro wrote:
> From: Michael J. Ruhl <michael.j.ruhl@intel.com>
> 
> If a MAD packet has incorrect header information, the logic uses the
> reply path to report the error.  The reply path expects *resp_len to
> be set prior to return.  Unfortunately, *resp_len is set to 0 for this
> path.  This causes an incorrect response packet.
> 
> Fix by ensuring that the *resp_len is defaulted to the incoming packet
> size (wc->bytes_len - sizeof(GRH)).
> 
> Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
> ---
>  drivers/infiniband/hw/hfi1/mad.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 0307405..88a0cf9 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -1,5 +1,5 @@ 
 /*
- * Copyright(c) 2015-2017 Intel Corporation.
+ * Copyright(c) 2015-2018 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -4836,7 +4836,7 @@  static int hfi1_process_opa_mad(struct ib_device *ibdev, int mad_flags,
 	int ret;
 	int pkey_idx;
 	int local_mad = 0;
-	u32 resp_len = 0;
+	u32 resp_len = in_wc->byte_len - sizeof(*in_grh);
 	struct hfi1_ibport *ibp = to_iport(ibdev, port);
 
 	pkey_idx = hfi1_lookup_pkey_idx(ibp, LIM_MGMT_P_KEY);