diff options
author | Ira Weiny <ira.weiny@intel.com> | 2018-09-20 15:58:46 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-09-20 21:24:51 -0400 |
commit | 0dbfaa9f2813787679e296eb5476e40938ab48c8 (patch) | |
tree | 4c235789be9a23c1387f3647ed884bba24817496 | |
parent | 4eeed3686981ff887bbdd7254139e2eca276534c (diff) |
IB/hfi1: Fix SL array bounds check
The SL specified by a user needs to be a valid SL.
Add a range check to the user specified SL value which protects from
running off the end of the SL to SC table.
CC: stable@vger.kernel.org
Fixes: 7724105686e7 ("IB/hfi1: add driver files")
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r-- | drivers/infiniband/hw/hfi1/verbs.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c index 13374c727b14..a7c586a5589d 100644 --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c | |||
@@ -1582,6 +1582,7 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr) | |||
1582 | struct hfi1_pportdata *ppd; | 1582 | struct hfi1_pportdata *ppd; |
1583 | struct hfi1_devdata *dd; | 1583 | struct hfi1_devdata *dd; |
1584 | u8 sc5; | 1584 | u8 sc5; |
1585 | u8 sl; | ||
1585 | 1586 | ||
1586 | if (hfi1_check_mcast(rdma_ah_get_dlid(ah_attr)) && | 1587 | if (hfi1_check_mcast(rdma_ah_get_dlid(ah_attr)) && |
1587 | !(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) | 1588 | !(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) |
@@ -1590,8 +1591,13 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr) | |||
1590 | /* test the mapping for validity */ | 1591 | /* test the mapping for validity */ |
1591 | ibp = to_iport(ibdev, rdma_ah_get_port_num(ah_attr)); | 1592 | ibp = to_iport(ibdev, rdma_ah_get_port_num(ah_attr)); |
1592 | ppd = ppd_from_ibp(ibp); | 1593 | ppd = ppd_from_ibp(ibp); |
1593 | sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)]; | ||
1594 | dd = dd_from_ppd(ppd); | 1594 | dd = dd_from_ppd(ppd); |
1595 | |||
1596 | sl = rdma_ah_get_sl(ah_attr); | ||
1597 | if (sl >= ARRAY_SIZE(ibp->sl_to_sc)) | ||
1598 | return -EINVAL; | ||
1599 | |||
1600 | sc5 = ibp->sl_to_sc[sl]; | ||
1595 | if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf) | 1601 | if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf) |
1596 | return -EINVAL; | 1602 | return -EINVAL; |
1597 | return 0; | 1603 | return 0; |