lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250221070301.18010-1-a.vatoropin@crpt.ru>
Date: Fri, 21 Feb 2025 07:03:09 +0000
From: Ваторопин Андрей <a.vatoropin@...t.ru>
To: Kai Shen <kaishen@...ux.alibaba.com>
CC: Ваторопин Андрей <a.vatoropin@...t.ru>, "Jason
 Gunthorpe" <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>, Wei Yongjun
	<weiyongjun1@...wei.com>, Yang Li <yang.lee@...ux.alibaba.com>,
	"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>
Subject: [PATCH] RDMA/erdma: handle ib_umem_find_best_pgsz() return value

From: Andrey Vatoropin <a.vatoropin@...t.ru>

The ib_umem_find_best_pgsz function is necessary for obtaining the optimal
hardware page size. In the comment above, function has statement: 
"Drivers always supporting PAGE_SIZE or smaller will never see a 0 result."

But it's hard to prove this holds true for the erdma driver.

Similar to other drivers that use ib_umem_find_best_pgsz, it is essential 
to add an error handler to manage potential error situations in the future.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 155055771704 ("RDMA/erdma: Add verbs implementation")
Signed-off-by: Andrey Vatoropin <a.vatoropin@...t.ru>
---
 drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/erdma/erdma_verbs.c b/drivers/infiniband/hw/erdma/erdma_verbs.c
index 51d619edb6c5..7ad38fb84661 100644
--- a/drivers/infiniband/hw/erdma/erdma_verbs.c
+++ b/drivers/infiniband/hw/erdma/erdma_verbs.c
@@ -781,6 +781,10 @@ static int get_mtt_entries(struct erdma_dev *dev, struct erdma_mem *mem,
 	mem->page_size = ib_umem_find_best_pgsz(mem->umem, req_page_size, virt);
+	if (!mem->page_size) {
+		ret = -EINVAL;
+		goto error_ret;
+	}
 	mem->page_offset = start & (mem->page_size - 1);
 	mem->mtt_nents = ib_umem_num_dma_blocks(mem->umem, mem->page_size);
 	mem->page_cnt = mem->mtt_nents;
 	mem->mtt = erdma_create_mtt(dev, MTT_SIZE(mem->page_cnt),
 				    force_continuous);
-- 
2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ