Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3497979imm; Sun, 16 Sep 2018 20:27:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJZ4DLCzFikCZQhyr7T0wfM3Gjd+DxIXow6NARi7uCmYvmeVn6LTDm3YkEkHl6vivaj7Ph X-Received: by 2002:a63:b19:: with SMTP id 25-v6mr21917444pgl.301.1537154841271; Sun, 16 Sep 2018 20:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154841; cv=none; d=google.com; s=arc-20160816; b=emOqaPlJlvYH+VDC1Lx09VugViw8wrgsk72Rn8tmqyjgkZ9W5aQcJee9PeWB9NPRp4 SOtHHEiNeEp61qylYj8h6xbo8vx3rKSM+pmOL2tzySYtrYvmUDxcZCEcjjM6LsATuk/W 7aI5L8Hgtfa646Rpflyn4wOXJsiV8QMzO8miwru4a5hmAQqoTXiyQheGghOD0cxFcYy3 C802Aez4Is9T9mCM36Nd7eLZ2CUXpWMHlZS+sfY+7I9brChLyWA0T8l7+VSDA1gms1Fd n+J4FzsB4ersLD69af419hz2HVsHuPM35SET0UL9ls+h+2fQ9QtsaUFWlpIl1bjS1Efx 6qvA== 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=+jnaoH0S3V4TkjLWiwdVDQWbItIymWbxHUBb2m5LioY=; b=DbbS4bbFzuaMbjtmZQ+B/AsV/12mnBuJQyipzFvAhAqYAVy8pb+QMgkr/ZmVEi45FL 8BKgotM51kejgx76q8IpZ7jF3ghJK0byd2Qvl9pNIIa2gtR80OuGnh9wPGWt7VVLR3He vgDHU0jRop2pCZxSUIpbbPMc340O5OzVulfaRPAtxFuR8vSwI0dX1E5BoenNDaKFUvHk S7Dl7AClk712wnfRwXBe5RBZTGD7EE1yzizj7QJxI0mybQV+qAatOlmwWW3/2mvkIPql 1LvXhZX11VQ5uPv5JSI7H3kfihFf6D5Ms4ZZG9eQhfHrZw4ccpvoaAzDYrFl2YK2ncJP LA/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GvIoPmlv; 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 91-v6si13771949ply.405.2018.09.16.20.27.06; Sun, 16 Sep 2018 20:27:21 -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=GvIoPmlv; 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 S1729813AbeIQI2s (ORCPT + 99 others); Mon, 17 Sep 2018 04:28:48 -0400 Received: from mail-by2nam03on0130.outbound.protection.outlook.com ([104.47.42.130]:60384 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729758AbeIQI2r (ORCPT ); Mon, 17 Sep 2018 04:28:47 -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=+jnaoH0S3V4TkjLWiwdVDQWbItIymWbxHUBb2m5LioY=; b=GvIoPmlvVRRMPojzJ6eQcngzqT6vbq5CpvYzRunHzgUy24a30XaBuvRKeNoohzfrcmAZhCKfogO41hF0Aq3EkoXIbJraqDgz6EFdbRpBfHEv8MD9NQBTCOw+pE7jwCUrNbH8ZM2lcI3ddAV0hwLcMxEkqFeMSKjkWkxvinpp+g0= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0855.namprd21.prod.outlook.com (10.173.192.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.4; Mon, 17 Sep 2018 03:03:29 +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:03:29 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Dan Carpenter , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 04/87] vmci: type promotion bug in qp_host_get_user_memory() Thread-Topic: [PATCH AUTOSEL 4.14 04/87] vmci: type promotion bug in qp_host_get_user_memory() Thread-Index: AQHUTjLd2H6zwutJ0EyZqm2KlvdDfQ== Date: Mon, 17 Sep 2018 03:02:26 +0000 Message-ID: <20180917030220.245686-4-alexander.levin@microsoft.com> References: <20180917030220.245686-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030220.245686-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;CY4PR21MB0855;6:spwcqE1aiawTA7X83lzFffYxf4G4VLmBXlZb6nMaBW57dKZ4yZXyuLixb8f/01PfNUrb/NFjN00iTL2AhWaZLFuAzQTdGw5tJo+3NBJgpG6ZwcVRLUPTFqb2xD+uvdx5PdmAZR5UR/CZfKmg6DRDEsoe19FO79AyOrSmxFsUz88JbmQbmZ8r8ZEfGa5HuqhjeZHMgocfliTI5rydxIoDrqWmU4lGKeEB+HsTPfBwtmKw+j1Wt0koPo1RL7DKaMDfV0SWu2vHHfjUMWyDM/oOqzvzlaq0SrabdYvEEegPdbJSGArYrW6tQqe2QolXigeZzhvOZ+Twp12odZ9k16+ShWb19AuPq/OhupGp3QSFNGt8s2Vev230p8irdSphoBYnNj32oUXNN1dpuzEugFlWdrJShCGVLSFNrwFZPdfQ0je8aA7PHptUSfqCDgCpDcTONi40bWsp6ZnLFcHdTD5BcA==;5:+rodRIeTI9NL61eOGJ3tCIiKQJPeMGK6IHTh25vNUkDxWfnGH9m1dIELV4Phi2OrOGFAsSMJzAk1inw5P0MHWrYnbf43O+E4JhgHEyNcrZW45bTb/zu5f6+dpqKLdpcM3V36Cri4qFP+j6v39HQznWB8E8wRlzqhkIzFE5m634Y=;7:blP+2enODkP2cET5LqhyzyPQretakVw5kIrBa1FWysKz9GwoHNoqUn4Siqg/1piv4diHJYPk3HdIO/F7rCjVkuzFZaUrMwBl7gcjHJg0XZ1wJyuIXq3UMeS98u5dQXWxxtiIA3tJv3M8aAnc8Z+25DLL8sW2ph8MPHYQyBFBLXid9CVVq9TcsWKmbT4ul5nV7jU8+4dz14LytMHtn61Em0AwayK70+Fn/cHr/s3/qr9LOCwwi93ILJfYKYmlom4+ x-ms-office365-filtering-correlation-id: 45dbd05c-0b96-446f-b853-08d61c4a24f5 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:CY4PR21MB0855; x-ms-traffictypediagnostic: CY4PR21MB0855: 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)(3231355)(944501410)(52105095)(2018427008)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699050)(76991041);SRVR:CY4PR21MB0855;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0855; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(136003)(366004)(199004)(189003)(6436002)(99286004)(7736002)(110136005)(54906003)(97736004)(5660300001)(66066001)(446003)(72206003)(76176011)(86362001)(86612001)(81166006)(81156014)(2906002)(478600001)(305945005)(68736007)(105586002)(2616005)(106356001)(476003)(11346002)(22452003)(6486002)(10090500001)(10290500003)(8676002)(36756003)(6346003)(6116002)(6506007)(3846002)(102836004)(107886003)(6666003)(6512007)(1076002)(25786009)(217873002)(4326008)(14454004)(26005)(256004)(486006)(186003)(316002)(2900100001)(8936002)(53936002)(5250100002)(2501003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0855;H:CY4PR21MB0776.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: Whi2qlJR6DnwXmls8pLQwcDW86kEOb7Nl/leR510Djj/1CXPyR7ly2H8j0uyy831ie9RCCYxRkI3z17vw/PqLnxa0herLXWTFMvIV0c0urCPePpdP16e/PzVmbE4Nq8ZcCYaPmzgCvtBASR1NJ8D0GBujP7iWCYzeAmiynYRayqKB4I+mEDcr0J10wgW5qhTyc4EM5C6WsaWK7D3mEYeSY3cZX0J/uahR329nM2f+LyOYfq/i4xt49K0ibCogGF5RX+j9M1xkLKcewrJwSJsU+e4omkqnvMzJDwKzKTvOlEr/eVEpt6r4E4LynKNqemAPnGucthpXOy7hIZOVBRxuzXrLMFCzFE7DPiBbPtc0YY= 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: 45dbd05c-0b96-446f-b853-08d61c4a24f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:02:26.9314 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0855 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 7fb2fd4e25fc1fb10dcb30b5519de257cfeae84c ] The problem is that if get_user_pages_fast() fails and returns a negative error code, it gets type promoted to a high positive value and treated as a success. Fixes: 06164d2b72aa ("VMCI: queue pairs implementation.") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/vmw_vmci/vmci_queue_pair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmc= i/vmci_queue_pair.c index 8af5c2672f71..b4570d5c1fe7 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -755,7 +755,7 @@ static int qp_host_get_user_memory(u64 produce_uva, retval =3D get_user_pages_fast((uintptr_t) produce_uva, produce_q->kernel_if->num_pages, 1, produce_q->kernel_if->u.h.header_page); - if (retval < produce_q->kernel_if->num_pages) { + if (retval < (int)produce_q->kernel_if->num_pages) { pr_debug("get_user_pages_fast(produce) failed (retval=3D%d)", retval); qp_release_pages(produce_q->kernel_if->u.h.header_page, @@ -767,7 +767,7 @@ static int qp_host_get_user_memory(u64 produce_uva, retval =3D get_user_pages_fast((uintptr_t) consume_uva, consume_q->kernel_if->num_pages, 1, consume_q->kernel_if->u.h.header_page); - if (retval < consume_q->kernel_if->num_pages) { + if (retval < (int)consume_q->kernel_if->num_pages) { pr_debug("get_user_pages_fast(consume) failed (retval=3D%d)", retval); qp_release_pages(consume_q->kernel_if->u.h.header_page, --=20 2.17.1