]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
IB/core: For multicast functions, verify that LIDs are multicast LIDs
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Sun, 9 Apr 2017 17:15:51 +0000 (10:15 -0700)
committerDoug Ledford <dledford@redhat.com>
Fri, 28 Apr 2017 17:48:01 +0000 (13:48 -0400)
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")
Cc: stable@vger.kernel.org
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>
drivers/infiniband/core/verbs.c

index 85ed5051fdfd3133dbf92025d3eab8118c3c8596..207e5c2457cc553b1e387faabb4f60f61e1dc496 100644 (file)
@@ -1519,7 +1519,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 < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
+           lid == be16_to_cpu(IB_LID_PERMISSIVE))
                return -EINVAL;
 
        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)
 
        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 < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
+           lid == be16_to_cpu(IB_LID_PERMISSIVE))
                return -EINVAL;
 
        ret = qp->device->detach_mcast(qp, gid, lid);