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-prev] [day] [month] [year] [list]
Message-ID: <a02b09d9-8b95-354f-dade-67240200d4fc@linux.alibaba.com>
Date: Fri, 21 Feb 2025 15:55:24 +0800
From: Cheng Xu <chengyou@...ux.alibaba.com>
To: Ваторопин Андрей
 <a.vatoropin@...t.ru>, Kai Shen <kaishen@...ux.alibaba.com>
Cc: 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: Re: [PATCH] RDMA/erdma: handle ib_umem_find_best_pgsz() return value



On 2/21/25 3:03 PM, Ваторопин Андрей wrote:
> 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;
> +	}

Thanks,

I think ib_umem_find_best_pgsz won't fail in erdma, because we always set the corresponding bit
of PAGE_SIZE in the req_page_size, which can let ib_umem_find_best_pgsz find an answer at least.

If fixing it can make SVACE happy, I'm OK with this patch.

Acked-by: Cheng Xu <chengyou@...ux.alibaba.com>

Regards,
Cheng Xu

>  	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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ