aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorMichael J. Ruhl <michael.j.ruhl@intel.com>2017-04-09 13:15:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:38 -0400
commit7a227630ab893f1aac6da6a540ebc2c6a7dce115 (patch)
treede6b2c7ffb8546e4220614f6a75d0df91684d31c /drivers/infiniband/core
parentecb0ab0f89c78c1bbe8386aac875f0b60753762d (diff)
IB/core: For multicast functions, verify that LIDs are multicast LIDs
commit 8561eae60ff9417a50fa1fb2b83ae950dc5c1e21 upstream. The Infiniband spec defines "A multicast address is defined by a MGID and a MLID" (section 10.5). Currently the MLID value is not validated. Add check to verify that the MLID value is in the correct address range. Fixes: 0c33aeedb2cf ("[IB] Add checks to multicast attach and detach") Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/verbs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 83687646da68..0e64b52af5b2 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1516,7 +1516,9 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
1516 1516
1517 if (!qp->device->attach_mcast) 1517 if (!qp->device->attach_mcast)
1518 return -ENOSYS; 1518 return -ENOSYS;
1519 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) 1519 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1520 lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1521 lid == be16_to_cpu(IB_LID_PERMISSIVE))
1520 return -EINVAL; 1522 return -EINVAL;
1521 1523
1522 ret = qp->device->attach_mcast(qp, gid, lid); 1524 ret = qp->device->attach_mcast(qp, gid, lid);
@@ -1532,7 +1534,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
1532 1534
1533 if (!qp->device->detach_mcast) 1535 if (!qp->device->detach_mcast)
1534 return -ENOSYS; 1536 return -ENOSYS;
1535 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) 1537 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1538 lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1539 lid == be16_to_cpu(IB_LID_PERMISSIVE))
1536 return -EINVAL; 1540 return -EINVAL;
1537 1541
1538 ret = qp->device->detach_mcast(qp, gid, lid); 1542 ret = qp->device->detach_mcast(qp, gid, lid);