]>
Commit | Line | Data |
---|---|---|
5032628c GKH |
1 | From 8561eae60ff9417a50fa1fb2b83ae950dc5c1e21 Mon Sep 17 00:00:00 2001 |
2 | From: "Michael J. Ruhl" <michael.j.ruhl@intel.com> | |
3 | Date: Sun, 9 Apr 2017 10:15:51 -0700 | |
4 | Subject: IB/core: For multicast functions, verify that LIDs are multicast LIDs | |
5 | ||
6 | From: Michael J. Ruhl <michael.j.ruhl@intel.com> | |
7 | ||
8 | commit 8561eae60ff9417a50fa1fb2b83ae950dc5c1e21 upstream. | |
9 | ||
10 | The Infiniband spec defines "A multicast address is defined by a | |
11 | MGID and a MLID" (section 10.5). Currently the MLID value is not | |
12 | validated. | |
13 | ||
14 | Add check to verify that the MLID value is in the correct address | |
15 | range. | |
16 | ||
17 | Fixes: 0c33aeedb2cf ("[IB] Add checks to multicast attach and detach") | |
18 | Reviewed-by: Ira Weiny <ira.weiny@intel.com> | |
19 | Reviewed-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> | |
20 | Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com> | |
21 | Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> | |
22 | Reviewed-by: Leon Romanovsky <leonro@mellanox.com> | |
23 | Signed-off-by: Doug Ledford <dledford@redhat.com> | |
24 | Signed-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); |