From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4A8EC4363C for ; Wed, 7 Oct 2020 11:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 960FB204FD for ; Wed, 7 Oct 2020 11:46:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgJGLqW (ORCPT ); Wed, 7 Oct 2020 07:46:22 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:47204 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726096AbgJGLqW (ORCPT ); Wed, 7 Oct 2020 07:46:22 -0400 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 1kQ7tf-0002Oh-Kz; Wed, 07 Oct 2020 11:46:15 +0000 From: Colin King To: Bjorn Helgaas , =?UTF-8?q?Christian=20K=C3=B6nig?= , Stephen Bates , Logan Gunthorpe , Alex Williamson , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel-janitors@vger.kernel.org Subject: [PATCH] PCI: fix a potential uninitentional integer overflow issue Date: Wed, 7 Oct 2020 12:46:15 +0100 Message-Id: <20201007114615.19966-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.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 using the BIT_ULL macro to perform the shift. Addresses-Coverity: ("Uninitentional integer overflow") Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable") Signed-off-by: Colin Ian King --- 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 6d4d5a2f923d..1a5844d7af35 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6209,7 +6209,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 = BIT_ULL(align_order); break; } else if (ret < 0) { pr_err("PCI: Can't parse resource_alignment parameter: %s\n", -- 2.27.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Colin King Date: Wed, 07 Oct 2020 11:46:15 +0000 Subject: [PATCH] PCI: fix a potential uninitentional integer overflow issue Message-Id: <20201007114615.19966-1-colin.king@canonical.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bjorn Helgaas , =?UTF-8?q?Christian=20K=C3=B6nig?= , Stephen Bates , Logan Gunthorpe , Alex Williamson , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel-janitors@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 using the BIT_ULL macro to perform the shift. Addresses-Coverity: ("Uninitentional integer overflow") Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable") Signed-off-by: Colin Ian King --- 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 6d4d5a2f923d..1a5844d7af35 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6209,7 +6209,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 = BIT_ULL(align_order); break; } else if (ret < 0) { pr_err("PCI: Can't parse resource_alignment parameter: %s\n", -- 2.27.0