Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4348377pxb; Tue, 10 Nov 2020 14:14:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC/t3AI4OyC/+2Yc8QFA1D/zek3rMAGHf4q0V8ZJUNnq/buSej8lfe/wtxJ2mE1OCVRDCe X-Received: by 2002:a17:906:5f8d:: with SMTP id a13mr22166037eju.194.1605046495456; Tue, 10 Nov 2020 14:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605046495; cv=none; d=google.com; s=arc-20160816; b=RumDVSoEEho2lDiMj7ve5ZABZdbxcF1DgNJzYDENd+IUxBXjBCJ7vIoVOXTsN/ikVD cMfsuYQ8H2lTxVwwVkQ47/N3ywTqcpCbRmVZAFE2zmnMNt2EVg5eodO8AIBZuFljqmv6 0pQf9c5e5b2JHQ8S1tQleGW5JWTuDs8sk40tsIJPP6Gx9tE6E8/yqwizKeo9kvOw4RwP eoIelXkVlGsuczqfVP6bYXOiZ3K+2Wz+nMUjtgu8YeZ27l4/6cqpAlOZ1PZWpom+sn0B oANC8Wlxyj0md4kDeRyNAfxBUkmh7c4+TxtSdC2xNuN2qiGh6gzsuA/eOYlhoSoL5FYg bOrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Qc1qZItNrvQEHY9UviDCcykAG2EOKBCrdJwdOmNgJKc=; b=nn76iKqccafkCoj78eY2f4QR0fppGsoNY4K+mB3ny6/KOYALBxKv0LttoOU146zFpA g+0PairY/obuNS8QNzkw4f/8G9322bFu7lTLHELBL0fw6njlVa6u1zWnCi7aHQtDD/K+ nYToEYbwqRz/sVpiHbYQ1gy5auPJ3SA3Vpkf/d+pNvqazE0TLxHtuQ/MS3spqrdYxyVa NlukP7T1Fj/Ly/uOpKa1XaKEJ30ODUvy8BstEulS9xKCWjVqvvGe6BVMRC4buhXQFdeq QkZG3HvSq34nXtMUQa/ZnQXaCXdl9/XSO1xUZugH+CWEM9wX2YyY02mLnzDPvu744yD4 42uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si37224ede.597.2020.11.10.14.14.31; Tue, 10 Nov 2020 14:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732100AbgKJWK6 (ORCPT + 99 others); Tue, 10 Nov 2020 17:10:58 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:56092 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731657AbgKJWKz (ORCPT ); Tue, 10 Nov 2020 17:10:55 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kcbqi-0005Ct-U2; Tue, 10 Nov 2020 22:10:49 +0000 From: Colin King To: Bjorn Helgaas , Stephen Bates , Alex Williamson , =?UTF-8?q?Christian=20K=C3=B6nig?= , Logan Gunthorpe , linux-pci@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][V2] PCI: Fix a potential uninitentional integer overflow issue Date: Tue, 10 Nov 2020 22:10:48 +0000 Message-Id: <20201110221048.3411288-1-colin.king@canonical.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The shift of 1 by align_order is evaluated using 32 bit arithmetic and the result is assigned to a resource_size_t type variable that is a 64 bit unsigned integer on 64 bit platforms. Fix an overflow before widening issue by making the 1 a ULL. Addresses-Coverity: ("Unintentional integer overflow") Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable") Signed-off-by: Colin Ian King --- V2: Use ULL instead of BIT_ULL(), fix spelling mistake and capitalize first word of patch subject. --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3ef63a101fa1..248044a7ef8c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6214,7 +6214,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, if (align_order == -1) align = PAGE_SIZE; else - align = 1 << align_order; + align = 1ULL << align_order; break; } else if (ret < 0) { pr_err("PCI: Can't parse resource_alignment parameter: %s\n", -- 2.28.0