Skip to content

Commit 8561eae

Browse files
mjruhldledford
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]>
1 parent 72fb70f commit 8561eae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/infiniband/core/verbs.c

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

15201520
if (!qp->device->attach_mcast)
15211521
return -ENOSYS;
1522-
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
1522+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1523+
lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1524+
lid == be16_to_cpu(IB_LID_PERMISSIVE))
15231525
return -EINVAL;
15241526

15251527
ret = qp->device->attach_mcast(qp, gid, lid);
@@ -1535,7 +1537,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
15351537

15361538
if (!qp->device->detach_mcast)
15371539
return -ENOSYS;
1538-
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
1540+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
1541+
lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
1542+
lid == be16_to_cpu(IB_LID_PERMISSIVE))
15391543
return -EINVAL;
15401544

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

0 commit comments

Comments
 (0)