From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0103.outbound.protection.outlook.com ([104.47.34.103]:19764 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755775AbeCSPrA (ORCPT ); Mon, 19 Mar 2018 11:47:00 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Tatyana Nikolova , Shiraz Saleem , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 003/124] i40iw: Validate correct IRD/ORD connection parameters Date: Mon, 19 Mar 2018 15:46:58 +0000 Message-ID: <20180319154645.11350-3-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Tatyana Nikolova [ Upstream commit ce9ce74145aa6814a370a9ff4f5a1d719baaced1 ] Casting to u16 before validating IRD/ORD connection parameters could cause recording wrong IRD/ORD values in the cm_node. Validate the IRD/ORD parameters as they are passed by the application before recording them. Fixes: f27b4746f378 ("i40iw: add connection management code") Signed-off-by: Tatyana Nikolova Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/i40iw/i40iw_cm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw= /i40iw/i40iw_cm.c index 77870f9e1736..726d7143475f 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_cm.c +++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c @@ -125,7 +125,8 @@ static u8 i40iw_derive_hw_ird_setting(u16 cm_ird) * @conn_ird: connection IRD * @conn_ord: connection ORD */ -static void i40iw_record_ird_ord(struct i40iw_cm_node *cm_node, u16 conn_i= rd, u16 conn_ord) +static void i40iw_record_ird_ord(struct i40iw_cm_node *cm_node, u32 conn_i= rd, + u32 conn_ord) { if (conn_ird > I40IW_MAX_IRD_SIZE) conn_ird =3D I40IW_MAX_IRD_SIZE; @@ -3849,7 +3850,7 @@ int i40iw_connect(struct iw_cm_id *cm_id, struct iw_c= m_conn_param *conn_param) } =20 cm_node->apbvt_set =3D true; - i40iw_record_ird_ord(cm_node, (u16)conn_param->ird, (u16)conn_param->ord)= ; + i40iw_record_ird_ord(cm_node, conn_param->ird, conn_param->ord); if (cm_node->send_rdma0_op =3D=3D SEND_RDMA_READ_ZERO && !cm_node->ord_size) cm_node->ord_size =3D 1; --=20 2.14.1