Received: by 10.213.65.68 with SMTP id h4csp1868310imn; Mon, 19 Mar 2018 15:47:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELuLLDB6+OAj0rh+3Px/bmF0mASXgMxjy6EMMZ+QmlMi/Hk9tuvz5bwLf2k3sIiEg3pVqKP3 X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr13981522pld.247.1521499636437; Mon, 19 Mar 2018 15:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521499636; cv=none; d=google.com; s=arc-20160816; b=HGGOInT5swfTp1/RJOxtYJamYMlS+mzS0avNTrPxXA8qBlHMOGc3yto18okwhUBFyQ jUu65UoxczzfSGiNHa4mpr6mqAnzQITKZnmntxewOvMTjfv8gKEgvkV7x5BYD0MwXt3v XYek8ggiBr6tNLZYWSVmC2Kf5nYnh48MiKKHWd74qG3jMi5jTSdaBwbYzTJqZiN5LgC6 vfoG7cGJcw8wXtgwv/b0FRYtSNkiwPU8GxsYQtE0Mj0vMnphdl7LkLGynyrAYA/BKdGy Nn//Ud1luu1uVLGq9UCkh4ks4oYRe2W91ubrHTdtdq/2dye2zqpFid2vmCUn9dISS3AC wMxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=AEJHIXLB25U83nb+H0i2fL+5tTVmxjE1z3g7e5f5rMA=; b=I4qE/56Ml2OWbmLIx2bhStzIZ8VilfsSYUsbuVIwzlSfggQRNqMgn734LRtpVBJwko qZnqVDLmp3rabT/82L4/Eaduv1eoOHAGvI+6JYpDlST8ZgM7mSj6HnkvzpToffqWeiQO mLqU8axMz2ZN5angn4KkeE7OIaWiySFSPetgRZ14ePDCHpoZYa2UesKO+Q6/KlUAn/Jl PFpLs3+nHjTdsSzCaYbAGxHSxvdxG6fP4x2It7FiJ+E25gT+cc3I4GCTq/D7OnZxQdDv k2lm6wviO923RGtLJZ4yoh/a2dKgOvQsRDpH5pZSXlBKY+2LQGa0qrKEICaVwY1N7qhf tKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dyHLCpDr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189si144076pge.444.2018.03.19.15.47.00; Mon, 19 Mar 2018 15:47:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dyHLCpDr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936814AbeCSWoB (ORCPT + 99 others); Mon, 19 Mar 2018 18:44:01 -0400 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AEJHIXLB25U83nb+H0i2fL+5tTVmxjE1z3g7e5f5rMA=; b=dyHLCpDrzz2x0WiGw7uJBLHhOKaPiGRl+UX9/PXjhrUzr6RixDaz+yk0aTQqfdGS00OIA2VmxZ8zw+5p6VbSJ2RmrVlbgQamuMOieu1xlpeWt6CUbOXiUEQzqwDjBkOhA9tQppjBWk4i4kLUuQGKK3yd3s5GuaTGqfkhqeUr8dY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1013.namprd21.prod.outlook.com (52.132.133.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 15:46:58 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:46:58 +0000 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 Thread-Topic: [PATCH AUTOSEL for 4.15 003/124] i40iw: Validate correct IRD/ORD connection parameters Thread-Index: AQHTv5mDvnmvcBocA0a0Vg2DJqqBhw== 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> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1013;7:Gv4Cc8LDBN1HnOpgBDPMBo66tJDj+9mkkbTxGihE/7j5voGzLzHVVQsZDAysN9W+RAckKHVVRb5TSrLrIcgTEbeejmvYKDzTD4vz2ZjaeLKnQvjM+sDZEG/vDknY2QKTrVMhtODk2zEVWLxrdudbNWgebMhf49tPKMovELc9f68Osd8Nns72Z5EsI9m2EnbSlP0BYIwe/W1xrAMiqV4za+UsUNeYKQuy1WW3Awj6IRy4s3di64cfOlgnuu6yOI20;20:1yW/1sXb31NRSej9nvzyG6PLReyjPCKDqE2R/AyIhoV3K/tSOtmURHFbbeDdaNV7ARgZVe74ZXSMa34Yob/K8rMvQzMtLGET+rEw/2WTyxV/hnN9XY1Q2vsA7y7lpzLaWyfJM5j+UgZTDaO3bE4tOqr83gmvLD3AuQ0dfk33yZw= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f4252253-0992-4849-1933-08d58db0a624 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1013; x-ms-traffictypediagnostic: DM5PR2101MB1013: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1013;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1013; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39860400002)(346002)(376002)(39380400002)(189003)(199004)(86612001)(316002)(26005)(72206003)(4326008)(25786009)(110136005)(10290500003)(86362001)(59450400001)(54906003)(53936002)(36756003)(107886003)(3280700002)(14454004)(22452003)(6506007)(5660300001)(68736007)(99286004)(186003)(478600001)(76176011)(2950100002)(10090500001)(102836004)(6116002)(5250100002)(2501003)(97736004)(3660700001)(106356001)(81156014)(81166006)(8676002)(8936002)(15650500001)(7736002)(305945005)(2900100001)(105586002)(3846002)(1076002)(66066001)(6436002)(2906002)(6512007)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1013;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: FYDcLsWhMiE8fIKUBKUaZYuZhkuvOMd7MoRg7qGkBbbIsKEC7V/2m+UCVa9hDh6QF/sA4PYSgVRxG81WX0t6sGGo6Abi2uO+dL6TwW0BlqwdZfsFtOdIz/GXL0HzwJ7IpQ5Hxm4q/e7Kvi6wnp/ks0kzUtCwZatHelCGNjBAQeBaym8hRTpbW72nQu/zbk3xJnJjWqco1OyCSGEWMFquJMclfgoLFhohIxeWKFrJSa4Q6RaJiSob2Mu2VfXtbYMoxsW7KHtw9VS0FAQJva1d3zvdsIXA9EUhs/rqLKtp5o39q9GMibWA1PVVNlsUvPbyXA836PQxAi38OJdPdkKEHQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4252253-0992-4849-1933-08d58db0a624 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:46:58.2105 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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