All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: fix a potential uninitentional integer overflow issue
@ 2020-10-07 11:46 ` Colin King
  0 siblings, 0 replies; 12+ messages in thread
From: Colin King @ 2020-10-07 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas, Christian König, Stephen Bates,
	Logan Gunthorpe, Alex Williamson, linux-pci, linux-kernel
  Cc: kernel-janitors

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-11-10 22:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 11:46 [PATCH] PCI: fix a potential uninitentional integer overflow issue Colin King
2020-10-07 11:46 ` Colin King
2020-10-07 12:33 ` Dan Carpenter
2020-10-07 12:33   ` Dan Carpenter
2020-11-05 22:24   ` Bjorn Helgaas
2020-11-05 22:24     ` Bjorn Helgaas
2020-11-06  8:04     ` Dan Carpenter
2020-11-06  8:04       ` Dan Carpenter
2020-11-10 20:54       ` Bjorn Helgaas
2020-11-10 20:54         ` Bjorn Helgaas
2020-11-10 22:00         ` Colin Ian King
2020-11-10 22:00           ` Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.