From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389384; b=Ig9hdbZWJoZGX0mkC5LGMs7xwabs+rqyQ4GN+x2epdg8JSGlL7HqzKCX/fcDldkkPTTu 40kcxaW+mtMD70c09aTaA9Qjz6nVzofvJ3nHeReGdtO6dRzcDYWbWA+K7ydgHBu3NbXZX nJPs6JpFwEENA/NRkmy7ZgXddhmGY/LBszRYqkot39O53eeWcQuB+t91DosOxr8hUZ8Yf 1d6xwQPa+DJ7jUor5cxf9r0sv8EfTmzzUWpw4WPts+yJKXLtRknmNRGh7MqxLcf/BrYMc tp6rBENOAxWFlAf/u9td9CLFAGrXi4Rw65QUSWO4eCR59paGkEHlJVQN7TO1+Zx9KfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389384; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=EZrGU5AahB4N26VJ9X0+ZgElG3OtSyl3YvhqswCLU7s=; b=FWn/v9NFT2k+K9whKYytn1gDEqvM461Mt4TvewtW/eQlSCkTJUMl/oP0LwpqX2mTUld4 cg/Bba1dwwqgMCjyNrn6zeDUXW+0smROa4pfvZwMlx/826/isgJ4dmiLH8KVSSoZhNhrm 56rdqD01MWz0tc+14CMeJ1LDF0Do2DokuL6ieMFNWVQRXeFXr8CbEwpo27kxeY7LajnN8 JfsMVMRlOAxKcCjJ1dukJ50/x/hhzYbn/j+ZC+Nb7FTJWlYBP3Lz4g0BJTg0r6G73Q4tN 7jpUGag5s1xDATYUJuMZLwROY+O6i8jT7Qy0fWIz1jPpVVAamMMDnfMwm37fD/GX6nQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=L6Uc70E3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A090606A322; Fri, 4 Dec 2026 13:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=L6Uc70E3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFFBD1F000C2; Fri, 4 Dec 2026 13:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389384; bh=EZrGU5AahB4N26VJ9X0+ZgElG3OtSyl3YvhqswCLU7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L6Uc70E30Suc4uy8EPdQcr9t/xImD+08QKC+ma4cvuBec01KA7XFnCKFVrH8hkf7N /uQqBUNeBqNoi7omxJRQo6qahULwf9FPAxmhiWAZ8WmmWQdUjl+85oh1QmXP4/o/98 TCcsP1yV2BenR1EQuLR2dXHdbE51C1T9F/QruItg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dezhen Lu , Jason Gunthorpe , Leon Romanovsky Subject: [PATCH 6.1 0970/1059] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Date: Fri, 4 Dec 2026 19:08:21 +0900 Message-ID: <20261204100709.141258734@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dezhen Lu commit b5c11bf9759834731440806708143c40638dc2ff upstream. devx_umem_find_best_pgsize() computes the page size in an unsigned long but returns it as unsigned int, and devx_umem_reg_cmd_alloc() stores it in an unsigned int. When the DMA mapping of the umem is contiguous and aligned to 4 GiB or more, and the umem length is a multiple of that size, ib_umem_find_best_pgoff() selects a page size >= 2^32. Since the value is a power of two, the truncation turns it into 0 and the registration fails with -EINVAL. The umem log_page_size field is 5 bits wide on top of MLX5_ADAPTER_PAGE_SHIFT, so the command can encode these page sizes. Seen on two GH200 nodes (ConnectX-7, firmware 32.38.3056 and 32.43.1014) with a dma-buf exported from cudaMalloc memory: registering 4 GiB or 8 GiB umems at 4 GiB-aligned offsets of the dma-buf fails with EINVAL every time, while 2 GiB umems at the same offsets and ibv_reg_dmabuf_mr() of the same ranges succeed. Restricting the user pgsz_bitmap to <= 2 GiB makes all of them succeed. Other large physically contiguous buffers, such as a 16 GiB hugetlb page on an arm64 kernel with 64K base pages, should hit the same path. Use unsigned long for the page size, as commit f0c2427412b4 ("RDMA/mlx5: Fix page_size variable overflow") already did for the MR paths. The bug was found by an AI coding assistant (Claude Opus 5.5, Anthropic) during an audit of 32-bit truncations of page sizes and offsets in drivers/infiniband/core and drivers/infiniband/hw/mlx5. The assistant also wrote the reproducer and this patch. The reproducer was run on the GH200 nodes described above. Fixes: 7610ab57de56 ("RDMA/mlx5: Allow larger pages in DevX umem") Cc: stable@vger.kernel.org Signed-off-by: Dezhen Lu Link: https://patch.msgid.link/20261103142804.67210-1-dezhen.lu@student.uni-tuebingen.de Reviewed-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx5/devx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/infiniband/hw/mlx5/devx.c +++ b/drivers/infiniband/hw/mlx5/devx.c @@ -2234,8 +2234,8 @@ static int devx_umem_get(struct mlx5_ib_ return 0; } -static unsigned int devx_umem_find_best_pgsize(struct ib_umem *umem, - unsigned long pgsz_bitmap) +static unsigned long devx_umem_find_best_pgsize(struct ib_umem *umem, + unsigned long pgsz_bitmap) { unsigned long page_size; @@ -2273,7 +2273,7 @@ static int devx_umem_reg_cmd_alloc(struc int access) { unsigned long pgsz_bitmap; - unsigned int page_size; + unsigned long page_size; __be64 *mtt; void *umem; int ret;