Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3504207imm; Sun, 16 Sep 2018 20:37:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZeTMYi8mwMcu+c/meuh9GWP3XytJdTGmJAHKANFVLnS7leSFh71SdHEHzMAKgPw6eY50Rd X-Received: by 2002:a17:902:1c5:: with SMTP id b63-v6mr23137812plb.82.1537155434407; Sun, 16 Sep 2018 20:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537155434; cv=none; d=google.com; s=arc-20160816; b=YNeu2DaMEh6+m6rBcCz1+RXRYBRjSVyasM3vozorgMQ+je5o0IqwzCT3Uhtiy9zpEY FyY2LQHNjPJ9gmzplrKbCVQdo1nRO4ZIKZoY7Ui+Mf716bjLR/frQBkf+HnGJM6+QYLd KVB/Kv8VJ24IDge2e8ghMic0KcaDx/0f6t2Eitjq/GbLM7hNqJK3LI3a28mOBfUMUez7 65CWXzGiAg67Dvk0jLNro5vmU7iyANfkJWjomN9k6go05UfjDKWqAbSx2vxCp5qs67gw f7DTyT23HZ1DazBgNAbzeQ0zCcHJWyg9W1wzUE6vImpxFllUq6oKFL86Sjs23BM3+xl5 yBCg== 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; bh=9Mwst/sAXbM7Wks5EwCnVMnq/ZjQe/b9wfKjg1QkG5Y=; b=i+MyAnp4XLWD2m0GTQp9JoZrlMUHr2vUYK5V+AurL724o98AudupAUO6KiACIpQSxj Har49TSH1NqXRELKFrOeBROgBUtKwkSkRr1zwjfvalKImqhsZEpXV52PIgxS655CCnDU VZ8RyNVNayx0DYSZWe3zLN5l0KSd4f+J8BLjz/KxKMyv4sWXkN4BArS0Rj8szLlzM0mV nJiT6uPNbRMIVj8Xthlk2ZmFqIk3QDK7RDjuWIJev+fWxDlztAQurAxP2HERad7o6vjp vVVAUME5S6Azn3KzalGPQLvtCGYardzCf8wh0JdCm7ne8nKQNwveqXWQmlGvm6i9el9T sRcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=acZecPjy; 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 b28-v6si14401430pfe.265.2018.09.16.20.36.59; Sun, 16 Sep 2018 20:37:14 -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=acZecPjy; 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 S1728816AbeIQI0U (ORCPT + 99 others); Mon, 17 Sep 2018 04:26:20 -0400 Received: from mail-eopbgr730108.outbound.protection.outlook.com ([40.107.73.108]:57545 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727242AbeIQI0T (ORCPT ); Mon, 17 Sep 2018 04:26:19 -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:X-MS-Exchange-SenderADCheck; bh=9Mwst/sAXbM7Wks5EwCnVMnq/ZjQe/b9wfKjg1QkG5Y=; b=acZecPjyzHYuuH4ixXvM/gKnwevVlW0jzp2HHFHlGnvcecsK8CRA9nchW37I7+ynqcJ8Cuic4rYKLCnpgkCVJnkJK3LWAp8QZCIxiJm+7abX1OXDih6Vdymn0BBBtbonlxFtk4duJJ3wOjqLtfzCb+Xqnb4rpZrCa9ZOhp1/o4g= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0629.namprd21.prod.outlook.com (10.175.115.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.13; Mon, 17 Sep 2018 03:01:02 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1185.003; Mon, 17 Sep 2018 03:01:02 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Dan Carpenter , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL 4.18 033/136] IB/core: type promotion bug in rdma_rw_init_one_mr() Thread-Topic: [PATCH AUTOSEL 4.18 033/136] IB/core: type promotion bug in rdma_rw_init_one_mr() Thread-Index: AQHUTjKZBRuOg4ht0EGKc+Yn0mSNZQ== Date: Mon, 17 Sep 2018 03:00:33 +0000 Message-ID: <20180917030006.245495-33-alexander.levin@microsoft.com> References: <20180917030006.245495-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030006.245495-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;CY4PR21MB0629;6:FyTmvmdw3x8ffvvTWVGxBs5EoM3XsTKd0PXg3m0D/4mjIVn88765VGAZwnqtixSb3ijgjK0ixPM0PCKQwzb3+EW77jeOrk/o3Pjcw3rIT2/KEaiKrLeRJ/vo++mSJKpqzJeU1088djV19fyqP6wSCskRIJioyxSQir1wYbvJjBqZ9xtpGsaz7SUXiBt7vmGuzQrJhBBro/Gb/gfVzU+MsMRotFF+spSEWItCbrLeh06WJVc/sC8i0Nfn5atkkaYPgdj782CA27vIKl0CcsLK/kDOJKHf2qy41CU0HxNZu+UfjX08l2kxpnfgObCjtkb0RDDycp/jWtTE4qSJi1cnG+AKI32fb0O36dW+UI1H7iAZgcejaD+hd7LgX991aGeePjQ1Gcksi/x+PhsHyFkrvNraNK2pCBrLHUb86MGp3yATebNf7xst7EDdsxO7VK+umZUvt3KVt21nJBWjsmaqHg==;5:DCC+XmuVPxHmStgqEv/YADDv/w6K8D192pewrvPhcFaodJMaQea2wYaOTFmGP90lACF1fDzGjYuwNIPrnJhzLM7byavvJ280MQE0PNsrkEeJigtv85+gyiWqSSeGWF5bSTFwlFyPVVp7HfcUh3q13vA5h6bcjhPwg3FQXYa5cXI=;7:jJ7IhD2etUQqvQOqT7X6LWroYNRjMPHroLNx/eeYhM3CnP4AP0lhabeYxSZnfiWJrn8sgG01GSDtGZjR9XTg5Y3S/a40AkZ826btHWAPdSpqYTlCObvyDeIia9e5UtpD159Hy1lfTnf7dOzZHAKODMH7Ctv0hKVgFCgI2Oz57qGRM8Z1ocsuH/y75sFGml+tQxkg5qKJkOMDK/WJf90Od45zxaeEANz644/1ORwidrJhveJGSKv1O8GP3zEqVUGl x-ms-office365-filtering-correlation-id: dff74d83-6f62-4510-0502-08d61c49cd8c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:CY4PR21MB0629; x-ms-traffictypediagnostic: CY4PR21MB0629: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(146099531331640)(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231355)(944501410)(52105095)(2018427008)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050)(76991041);SRVR:CY4PR21MB0629;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0629; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(39860400002)(376002)(396003)(136003)(189003)(199004)(76176011)(1076002)(86612001)(105586002)(22452003)(5250100002)(6666003)(7736002)(68736007)(4326008)(86362001)(575784001)(2501003)(99286004)(6116002)(3846002)(36756003)(107886003)(72206003)(25786009)(106356001)(14454004)(6436002)(5660300001)(10290500003)(486006)(2616005)(446003)(6506007)(11346002)(97736004)(256004)(476003)(478600001)(305945005)(14444005)(217873002)(81166006)(102836004)(6512007)(8676002)(6486002)(2906002)(66066001)(2900100001)(186003)(26005)(54906003)(316002)(53936002)(8936002)(10090500001)(81156014)(110136005);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0629;H:CY4PR21MB0776.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: GYkgG+/11C6s3VCr9qXHE+v7uV0sqTFuSrF/q0/cdODvfyoU/EK29vvdHeD9jn8jaWWi3n6DfY2takUvu1plynUEVhOj/e4LGFsMJP4QwTQerj765x6OBEIgpL2gELoFJK2EeGuOc9wG6hhtSAimtC6VsRc23MG3DrBWYpq6QUq7IxIjjVBGvmR06tx2gpUOTztxMFPCjFA4ptRKBxhB3pvyc75WrHnsM2JgWQhooLzBtNAiibfpCvZ2wwdi4kYXjL5H9c9uO/PoWlTIlRVujgeYwHvJMHpEmwk40xn4wqUP6al53iGrLmPbkH/w77yzxRBaNHlNXj8GLLQK93ltp43S3rGHheplWSHXV7q5qnw= 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: dff74d83-6f62-4510-0502-08d61c49cd8c X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:00:33.1672 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0629 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit c2d7c8ff89b22ddefb1ac2986c0d48444a667689 ] "nents" is an unsigned int, so if ib_map_mr_sg() returns a negative error code then it's type promoted to a high unsigned int which is treated as success. Fixes: a060b5629ab0 ("IB/core: generic RDMA READ/WRITE API") Signed-off-by: Dan Carpenter Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c index c8963e91f92a..3ee0adfb45e9 100644 --- a/drivers/infiniband/core/rw.c +++ b/drivers/infiniband/core/rw.c @@ -87,7 +87,7 @@ static int rdma_rw_init_one_mr(struct ib_qp *qp, u8 port_= num, } =20 ret =3D ib_map_mr_sg(reg->mr, sg, nents, &offset, PAGE_SIZE); - if (ret < nents) { + if (ret < 0 || ret < nents) { ib_mr_pool_put(qp, &qp->rdma_mrs, reg->mr); return -EINVAL; } --=20 2.17.1