]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.2/ib-core-for-multicast-functions-verify-that-lids-are-multicast-lids.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.2 / ib-core-for-multicast-functions-verify-that-lids-are-multicast-lids.patch
CommitLineData
5032628c
GKH
1From 8561eae60ff9417a50fa1fb2b83ae950dc5c1e21 Mon Sep 17 00:00:00 2001
2From: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
3Date: Sun, 9 Apr 2017 10:15:51 -0700
4Subject: IB/core: For multicast functions, verify that LIDs are multicast LIDs
5
6From: Michael J. Ruhl <michael.j.ruhl@intel.com>
7
8commit 8561eae60ff9417a50fa1fb2b83ae950dc5c1e21 upstream.
9
10The Infiniband spec defines "A multicast address is defined by a
11MGID and a MLID" (section 10.5). Currently the MLID value is not
12validated.
13
14Add check to verify that the MLID value is in the correct address
15range.
16
17Fixes: 0c33aeedb2cf ("[IB] Add checks to multicast attach and detach")
18Reviewed-by: Ira Weiny <ira.weiny@intel.com>
19Reviewed-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
20Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
21Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
22Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
23Signed-off-by: Doug Ledford <dledford@redhat.com>
24Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26---
27 drivers/infiniband/core/verbs.c | 8 ++++++--
28 1 file changed, 6 insertions(+), 2 deletions(-)
29
30--- a/drivers/infiniband/core/verbs.c
31+++ b/drivers/infiniband/core/verbs.c
32@@ -1519,7 +1519,9 @@ int ib_attach_mcast(struct ib_qp *qp, un
33
34 if (!qp->device->attach_mcast)
35 return -ENOSYS;
36- if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
37+ if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
38+ lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
39+ lid == be16_to_cpu(IB_LID_PERMISSIVE))
40 return -EINVAL;
41
42 ret = qp->device->attach_mcast(qp, gid, lid);
43@@ -1535,7 +1537,9 @@ int ib_detach_mcast(struct ib_qp *qp, un
44
45 if (!qp->device->detach_mcast)
46 return -ENOSYS;
47- if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
48+ if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
49+ lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
50+ lid == be16_to_cpu(IB_LID_PERMISSIVE))
51 return -EINVAL;
52
53 ret = qp->device->detach_mcast(qp, gid, lid);