diff mbox

[v2,1/2] RDMA/uverbs: Fix the check for port number

Message ID 1500043291-19768-2-git-send-email-mustafa.ismail@intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Ismail, Mustafa July 14, 2017, 2:41 p.m. UTC
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(-)

Comments

Marciniszyn, Mike July 17, 2017, 7:10 p.m. UTC | #1
> 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>
--
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
diff mbox

Patch

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;
 	}