diff options
author | Michael J. Ruhl <michael.j.ruhl@intel.com> | 2017-04-09 20:15:51 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-08-26 04:14:03 +0300 |
commit | 258132a3ab98637570e7961fe29cdcad408a7912 (patch) | |
tree | b39a521be3398cf9c00b734e333ecef5340e3095 /drivers | |
parent | 748b9d53f2187cc7baf3a317d85f579de5b5d839 (diff) | |
download | linux-258132a3ab98637570e7961fe29cdcad408a7912.tar.xz |
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>
[bwh: Backported to 3.2: use literal number instead of IB_MULTICAST_LID_BASE]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/verbs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 575b78045aaf..45a67442d389 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1185,7 +1185,9 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid) { if (!qp->device->attach_mcast) return -ENOSYS; - if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) + if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD || + lid < 0xC000 || + lid == be16_to_cpu(IB_LID_PERMISSIVE)) return -EINVAL; return qp->device->attach_mcast(qp, gid, lid); @@ -1196,7 +1198,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid) { if (!qp->device->detach_mcast) return -ENOSYS; - if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) + if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD || + lid < 0xC000 || + lid == be16_to_cpu(IB_LID_PERMISSIVE)) return -EINVAL; return qp->device->detach_mcast(qp, gid, lid); |