Skip to content

Commit 18874f8

Browse files
mjruhlBrian Maly
authored andcommitted
IB/core: For multicast functions, verify that LIDs are multicast LIDs
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: 0c33aee ("[IB] Add checks to multicast attach and detach") Cc: [email protected] Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Dasaratharaman Chandramouli <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]> (cherry picked from commit 8561eae) The reason for applying this patch is a bug in ibacm, which goes undetected without this patch. For further information, see https://patchwork.kernel.org/patch/10008461/ Signed-off-by: Brian Maly <[email protected]> Conflicts: * Had to add the define IB_MULTICAST_LID_BASE in include/rdma/ib_verbs.h, due to missing commit b4e6439 ("IB/rdmavt: Break rdma_vt main include header file up"). Orabug: 28700490 Signed-off-by: Håkon Bugge <[email protected]> Reviewed-by: Shannon Nelson <[email protected]> --- v2 -> v3: * Added Shannon's r-b v1 -> v2: * Adding IB_MULTICAST_LID_BASE to ib_verbs.h * A little more verbose commit message Signed-off-by: Brian Maly <[email protected]>
1 parent 37d4183 commit 18874f8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,9 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
14171417

14181418
if (!qp->device->attach_mcast)
14191419
return -ENOSYS;
1420-
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
1420+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1421+
lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1422+
lid == be16_to_cpu(IB_LID_PERMISSIVE))
14211423
return -EINVAL;
14221424

14231425
ret = qp->device->attach_mcast(qp, gid, lid);
@@ -1433,7 +1435,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
14331435

14341436
if (!qp->device->detach_mcast)
14351437
return -ENOSYS;
1436-
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
1438+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1439+
lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1440+
lid == be16_to_cpu(IB_LID_PERMISSIVE))
14371441
return -EINVAL;
14381442

14391443
ret = qp->device->detach_mcast(qp, gid, lid);

include/rdma/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ enum {
469469
};
470470

471471
#define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF)
472+
#define IB_MULTICAST_LID_BASE cpu_to_be16(0xC000)
472473

473474
enum ib_ah_flags {
474475
IB_AH_GRH = 1

0 commit comments

Comments
 (0)