All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: linux-rdma@vger.kernel.org, Leon Romanovsky <leon@kernel.org>,
	Daniel Jurgens <danielj@mellanox.com>,
	stable@vger.kernel.org
Subject: [PATCH rdma-rc 1/4] IB/core: Bound check alternate path port number
Date: Tue,  5 Dec 2017 22:30:01 +0200	[thread overview]
Message-ID: <20171205203004.28386-2-leon@kernel.org> (raw)
In-Reply-To: <20171205203004.28386-1-leon@kernel.org>

From: Daniel Jurgens <danielj@mellanox.com>

The alternate port number is used as an array index in the IB
security implementation, invalid values can result in a kernel panic.

Cc: <stable@vger.kernel.org> # v4.12
Fixes: d291f1a65232 ("IB/core: Enforce PKey security on QPs")
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
 drivers/infiniband/core/uverbs_cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 16d55710b116..d0202bb176a4 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1971,6 +1971,12 @@ static int modify_qp(struct ib_uverbs_file *file,
 		goto release_qp;
 	}
 
+	if ((cmd->base.attr_mask & IB_QP_ALT_PATH) &&
+	    !rdma_is_port_valid(qp->device, cmd->base.alt_port_num)) {
+		ret = -EINVAL;
+		goto release_qp;
+	}
+
 	attr->qp_state		  = cmd->base.qp_state;
 	attr->cur_qp_state	  = cmd->base.cur_qp_state;
 	attr->path_mtu		  = cmd->base.path_mtu;
-- 
2.15.1

  reply	other threads:[~2017-12-05 20:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 20:30 [PATCH rdma-rc 0/4] RDMA fixes for 4.15 Leon Romanovsky
2017-12-05 20:30 ` Leon Romanovsky [this message]
2017-12-05 20:30 ` [PATCH rdma-rc 2/4] IB/core: Don't enforce PKey security on SMI MADs Leon Romanovsky
     [not found] ` <20171205203004.28386-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-05 20:30   ` [PATCH rdma-rc 3/4] IB/mlx4: Fix RSS hash fields restrictions Leon Romanovsky
2017-12-05 20:30   ` [PATCH rdma-rc 4/4] RDMA/netlink: Fix general protection fault Leon Romanovsky
2017-12-07 20:50   ` [PATCH rdma-rc 0/4] RDMA fixes for 4.15 Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171205203004.28386-2-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=danielj@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.