提交 136acd7e 编写于 作者: C Colin Ian King 提交者: Xie XiuQi

PCI: Fix overflow in command-line resource alignment requests

stable inclusion
from stable-5.10.4
commit 2df49a5de565ba5ed1c492e83e01b7d5d7c3a35d
bugzilla: 46903

--------------------------------

[ Upstream commit cc73eb32 ]

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: 32a9a682 ("PCI: allow assignment of memory resources with a specified alignment")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: NLogan Gunthorpe <logang@deltatee.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 6ee8c14f
...@@ -6216,7 +6216,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, ...@@ -6216,7 +6216,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev,
ret = pci_dev_str_match(dev, p, &p); ret = pci_dev_str_match(dev, p, &p);
if (ret == 1) { if (ret == 1) {
*resize = true; *resize = true;
align = 1 << align_order; align = 1ULL << align_order;
break; break;
} else if (ret < 0) { } else if (ret < 0) {
pr_err("PCI: Can't parse resource_alignment parameter: %s\n", pr_err("PCI: Can't parse resource_alignment parameter: %s\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册