Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3711615imu; Mon, 28 Jan 2019 09:27:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN6LmcJmDHvwryOxFM2/V3k2dKr0qE8OBOUxkSs2lstijoRNFmJub71+jdXIaZYrd4EWJf09 X-Received: by 2002:a65:43c5:: with SMTP id n5mr21102639pgp.250.1548696427439; Mon, 28 Jan 2019 09:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696427; cv=none; d=google.com; s=arc-20160816; b=OIsXKZypE9EZdA+A0DUKbH1GmmNRoSglHmNAcKQMFkZs2PC8Vhy/DfrAKDgWUxuaqA Cssjf9RdClucbc8pYKdLivXpcZyrIBBMuM33/oYSPCYitJ6MC5qDtm7FS87zUgZr+cqA oT4G53x4CTm4/qZoWfHvnECXA4rYwAp7aviiRIdK0H+iu1Jz/09KnNCFyBe4ywynx182 5QBa+hCgZzJ0wnc8rxp4Hhjyx7Kklt7Zeo0gBv+UiduImyodLWX9vTh/P81ZHWYgSgpK UqXpbUnfho1swtOWFV4iXFHkavkPNB4BSFewjDsitlyGjohmobVbcH468MR111laJwaX 9q8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2ACssLvsxrxRoH2PzXgPikf2hibMF9RpB2BxxtWuqOw=; b=JnX6fxh65ZLC9roEDJFBVwkyIWUnYFLqqVJ2Niv7K6TJYuWPlFV6h0hEcjmc7UbjCG +ZAhjlMMvkiIjKFZFiallEdQ7Dym1AmV3Zk8oqk6SU1qT7r5tnlphfJZLsB6N6QF3Rkp /S1ZQab/ZhS90u3TRqNoPoQnaimwcVXCn2U8YdxqVr5tlqcfjTt3auv8jkxCKnlwfo8Y DGNJM80UDrGzzcnTmcUsX3ft9ZkwXUKhypRtf9V0NvdE1iuu60PhOq85uC5kCJEhlCzU uQJ5n4vW/39HpYZJZFupcNbCX5vNTWjWRPw9+zl7UR6N3yt95qJU3ppfzOZrkSjeOUIb Dpcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P3PJGx6c; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si34315627pla.352.2019.01.28.09.26.51; Mon, 28 Jan 2019 09:27:07 -0800 (PST) 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=@kernel.org header.s=default header.b=P3PJGx6c; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730797AbfA1QA3 (ORCPT + 99 others); Mon, 28 Jan 2019 11:00:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:45688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730754AbfA1QA0 (ORCPT ); Mon, 28 Jan 2019 11:00:26 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 856872175B; Mon, 28 Jan 2019 16:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691226; bh=hIsqLgJIVecRCPkiS/x7U8wfvg+g3uWTtxMvbTqZBms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3PJGx6c6K065jiagpFpMA2mEaBHRSnEv/p7XDlXG9cm5aODwykF0C047a66yiFSm pFecePzz0cb9e8vTjhjGYwwitoipeBxxhmnG7SNXgW4RlN/b5pTAufRXOx0w1gH/EG kwXJSxWJO2B0mIUR+ItdTYtsWT0GzsTdnuuUSxRs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Colin Ian King , Bjorn Helgaas , Sasha Levin , linux-pci@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 022/258] x86/PCI: Fix Broadcom CNB20LE unintended sign extension (redux) Date: Mon, 28 Jan 2019 10:55:28 -0500 Message-Id: <20190128155924.51521-22-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 53bb565fc5439f2c8c57a786feea5946804aa3e9 ] In the expression "word1 << 16", word1 starts as u16, but is promoted to a signed int, then sign-extended to resource_size_t, which is probably not what was intended. Cast to resource_size_t to avoid the sign extension. This fixes an identical issue as fixed by commit 0b2d70764bb3 ("x86/PCI: Fix Broadcom CNB20LE unintended sign extension") back in 2014. Detected by CoverityScan, CID#138749, 138750 ("Unintended sign extension") Fixes: 3f6ea84a3035 ("PCI: read memory ranges out of Broadcom CNB20LE host bridge") Signed-off-by: Colin Ian King Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- arch/x86/pci/broadcom_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/broadcom_bus.c b/arch/x86/pci/broadcom_bus.c index 526536c81ddc..ca1e8e6dccc8 100644 --- a/arch/x86/pci/broadcom_bus.c +++ b/arch/x86/pci/broadcom_bus.c @@ -50,8 +50,8 @@ static void __init cnb20le_res(u8 bus, u8 slot, u8 func) word1 = read_pci_config_16(bus, slot, func, 0xc0); word2 = read_pci_config_16(bus, slot, func, 0xc2); if (word1 != word2) { - res.start = (word1 << 16) | 0x0000; - res.end = (word2 << 16) | 0xffff; + res.start = ((resource_size_t) word1 << 16) | 0x0000; + res.end = ((resource_size_t) word2 << 16) | 0xffff; res.flags = IORESOURCE_MEM; update_res(info, res.start, res.end, res.flags, 0); } -- 2.19.1