[openib-general] [PATCH] check for valid MGID in user space

Jack Morgenstein jackm at mellanox.co.il
Thu Sep 22 05:45:11 PDT 2005


The following patch checks validity of MGID when attaching/detaching a QP to/from 
a multicast group (for user-space only). IB spec demands that multicast gids start 
with 0xFF in 0-th byte. (IB Spec v1.2,section 4.1.1 (page 144)).


Index: linux-kernel/infiniband/core/uverbs_cmd.c
===================================================================
--- linux-kernel/infiniband/core/uverbs_cmd.c	(revision 3505)
+++ linux-kernel/infiniband/core/uverbs_cmd.c	(working copy)
@@ -1040,7 +1040,7 @@
 	down(&ib_uverbs_idr_mutex);
 
 	qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
-	if (qp && qp->uobject->context == file->ucontext)
+	if (qp && qp->uobject->context == file->ucontext && cmd.gid[0] == 0xFF)
 		ret = ib_attach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
 
 	up(&ib_uverbs_idr_mutex);
@@ -1062,7 +1062,7 @@
 	down(&ib_uverbs_idr_mutex);
 
 	qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
-	if (qp && qp->uobject->context == file->ucontext)
+	if (qp && qp->uobject->context == file->ucontext && cmd.gid[0] == 0xFF)
 		ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
 
 	up(&ib_uverbs_idr_mutex);



More information about the general mailing list