Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2678907imj; Mon, 11 Feb 2019 06:55:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IY7U/ldGYwPT61YKu8SmZ8NuVSgIoLla/IMx+pJINrCc6LRm5LxERXBxF19WdCir91IMx+f X-Received: by 2002:aa7:8508:: with SMTP id v8mr6288701pfn.14.1549896948923; Mon, 11 Feb 2019 06:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549896948; cv=none; d=google.com; s=arc-20160816; b=i4NtRO5ScU0hXY4feUAibbw649kHxs0Hs6XWe8eBK1dgP26FQ923ulmtMvNWbsUCGC bqdCOAFrtwg/ppDtj0gMvJGLGsvAfnfhSP0/ejJDgD6TYIVzvsqsK+xoQPEYC0iQpSMy tjbg83FDiPz85pUhRQBIQopO51T2f75TpnmIBwiBvaqBz9rGK1BrF+IiA4IgGj9MZXhg yycIREF1AzTnBuKGO/oEsCHP53alrmaOXX4YqIu/M1LuQMtVN8njCLeAYFlQuZZKNdAs DgYzCt/OyRvcvArtQBk6HN4LQPeEevChP0uwDDfXHu0uYwSdRoXnmV6TStrFIwBaHeXh hw7g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bQy2mwAmeNwwpA5J1uGh5LSXPEVaRbhTVBiF7cgyLPI=; b=X87Dl1ZjOH/5ZMI9vZdyjMHvOgiiR5Q2Kl0xC3Rx3XvAuFuY/3hZ84l2/OpWB+chL/ 7j9rS76NgrFjLV2yt9AjkyeAy5N5SI4phCPQV32Yrap4jly1K9xo3tE3oqKr7e0aFlSe kIWKnsJ3iuaSZgQNb2qI2lv0N3oCaYXQwQppN03QFWmhGyw4pzqPinU9bHNwaee1CslM 6zSBnNNwFZ2i+/fQJZSCXF/S1hqp/42pNOvm8E2JlljwgGYEl5G1LAM4C4GElR395vZ4 5vrEJH/bclhfX7w6chcNrk0JXxT1zPZ82n22Y9gOVfwG44kk6Rp0tHWaW3JBrtdF/WSB NtKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nOeZ1Ajf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si9417558pgl.528.2019.02.11.06.55.31; Mon, 11 Feb 2019 06:55:48 -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=nOeZ1Ajf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388836AbfBKOy3 (ORCPT + 99 others); Mon, 11 Feb 2019 09:54:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:41152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388823AbfBKOyZ (ORCPT ); Mon, 11 Feb 2019 09:54:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79608222A1; Mon, 11 Feb 2019 14:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896865; bh=9ThkZTxMZMvJfhsQTgsw98M+U51sxbfRbD9vt0ybfj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOeZ1AjfOJRbs3mPPxK6JaIMIbzH/QnxTGcOZP4i4BVD3Um9FXfUJ/TSK9MR2No4T ED6Tz1SSl78CO25/L3/9FECW2/pjqLH5GoOtkI3Dzp1tAGjWD2Cos1pr2Sx05Ll+8h TmNIGV1HFTpI/jT+N0voEd3sW65TT5zmDycILaSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Bjorn Helgaas , Sasha Levin Subject: [PATCH 4.14 014/205] x86/PCI: Fix Broadcom CNB20LE unintended sign extension (redux) Date: Mon, 11 Feb 2019 15:16:52 +0100 Message-Id: <20190211141828.083712368@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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