Skip to content

Commit 0c33aee

Browse files
Jack MorgensteinRoland Dreier
authored andcommitted
[IB] Add checks to multicast attach and detach
Add checks so that we only allow multicast attach/detach with a valid multicast GID and the correct QP type. Signed-off-by: Jack Morgenstein <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 2cc78eb commit 0c33aee

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,22 @@ EXPORT_SYMBOL(ib_dealloc_fmr);
523523

524524
int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
525525
{
526-
return qp->device->attach_mcast ?
527-
qp->device->attach_mcast(qp, gid, lid) :
528-
-ENOSYS;
526+
if (!qp->device->attach_mcast)
527+
return -ENOSYS;
528+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
529+
return -EINVAL;
530+
531+
return qp->device->attach_mcast(qp, gid, lid);
529532
}
530533
EXPORT_SYMBOL(ib_attach_mcast);
531534

532535
int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
533536
{
534-
return qp->device->detach_mcast ?
535-
qp->device->detach_mcast(qp, gid, lid) :
536-
-ENOSYS;
537+
if (!qp->device->detach_mcast)
538+
return -ENOSYS;
539+
if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
540+
return -EINVAL;
541+
542+
return qp->device->detach_mcast(qp, gid, lid);
537543
}
538544
EXPORT_SYMBOL(ib_detach_mcast);

0 commit comments

Comments
 (0)