Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2775580imj; Mon, 11 Feb 2019 08:16:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IbHY8wKXwBGbRtavhd1TXw/eT569Y5hP1s/rjKRS0UW9N0hsACCYEiCwjraH0/OpPee/mxs X-Received: by 2002:a17:902:449:: with SMTP id 67mr29620836ple.310.1549901817941; Mon, 11 Feb 2019 08:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901817; cv=none; d=google.com; s=arc-20160816; b=w+KDVW6yUk6k6iCBDsziIlbMuZ275x3ghamkTTwXMwzWtxnYIk2NFFaWcrhagzwpZq drypjekkT4OLN8wMAXzXvbeRCc3XMitoPWIMuRqTaFK6JgFPE2gQ95gVW/tQkQTgYom+ utIZZLSt1FXQ+MaR8luAEOue2Md5GwpZaKRxphhtLag0nZvR9aXkB1kwzFf9nqTZIuDm ti0pe1v6XUq4RunRWJTy8JZnMCQ/m1TeOWE/34GI7IribDDXc4gY5aGPe9IFnFMwkauT 2PO/8a5I7fBWuHZvGDmCDnYdn6kSAxLr3vZRqbYg+d7Z9g7QPfqwmcbT88Fx1Sfk59JC 25Ww== 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=ZQ5oa5l1SPJfxs1Gt0Lc0BNdKkTHKnC8mlk0Uq2DhhA=; b=IU+NAKtCiFXxXGMhwofvDRy9wtyyCW60PdI0RCvcC8ZJtpsVJYsJmF0q+6JOFvoP4r 2k1reCnVVxzszEqE1a7aZ18MkcMUrMu7ccXzUCGvNwzSf/j69DsylQ4hrEHIsYYxRxal w19bwgz1buV26qDu629lIS6POk8mXJ2dVqe0k5DcZgetfNk0821PdqvSsoNCj23iBFcl lp6ovSwxoUADwabUGqopuYYeGoAuaG4bAmcsOvP34BWE7E0DhVQzyVJw4XkwKJB983u4 uH43NY+1LjU2NrQMHB0Nyae35gh36j1AOyHQUtwIB3uXK3ttvupa1qbrzmE+xfe/Vk1o voDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BjrkjLM9; 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 b6si10243095pls.367.2019.02.11.08.16.30; Mon, 11 Feb 2019 08:16:57 -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=BjrkjLM9; 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 S1727732AbfBKOVj (ORCPT + 99 others); Mon, 11 Feb 2019 09:21:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:54436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727671AbfBKOVh (ORCPT ); Mon, 11 Feb 2019 09:21:37 -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 E0E46222B5; Mon, 11 Feb 2019 14:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549894896; bh=yvSG2Zd5UEktKEpGNzKa24YCiM8ohfAJT/tXMyIHmmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjrkjLM9uV86e8d4Q0nHD2KLqi29WgilM6RNdsKwm+TbX/XScaE0ql6i/O7RHBS23 l693w+Iud4gCb5lKVCKVuZs+dgm+sWdf/687snuRgBqKfdY6EdU5OYc3iSL1kul50+ k9DUC68kv0lzFMZgx2/OK9TLKs7grsDyTKz6PqAU= 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.20 025/352] x86/PCI: Fix Broadcom CNB20LE unintended sign extension (redux) Date: Mon, 11 Feb 2019 15:14:12 +0100 Message-Id: <20190211141847.948403595@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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