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=1796382627; b=1jf2qHHw3ApY7MVCtKHzoVqvJYkrNvUizZTx8wWx+VY/ZRZjM1ZwgdXo0m1VPFFmnIDL WCM5zARDP2l/MTrFhUWEe9k8BKda/Ww5GIehb7HZ0KhW7j6psG28h3+spgz12C5Rhtdqo OjNxD20kcHDm0LeGByiXrK4p+q21KLO8V2tLTjklnXUlGo5DCwxu1M2TjZKBwdih1sFRh mbWGkuXwdKHMFMZM/ICEJZFpUJNymRqzfMjPURSsXG8Oil1muy5FjiMDmovjPlhdkip2c xKAAtEZRtxh+yZ95nSkc4iQS9FXTmqnAwGBwmMn8Ni/OuTzrkvNMc+l/I6RNPvSMeJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382627; 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=QnBeBdhHkcMoFmPD0xHFtIOkbhETScdJLl7sOfz7Q1k=; b=H4pPKlwcDZ4Mf0HfIPWl7ebJS3f7h32VoDgJOMzArFB0C9f4CKw1j1ePTBL3DW8fV6GT MAs8qDn34DOO9l6quzcVkfDldz9CnzL6rKUIbdJI20LQII5O3Y+a8IpGBJ206DDdmPohq 3b1fQCGY1a8DuSGoA3CPEvstJUKdgKnZBcuAdwPkjGnwaKMuinpBLfvq2vYdVsS0alDyB n+tQnJfdpnSKC/KG5HEwN0kKfHCmxZde+CYi9TdM1z+mfI8rll91f+fiFLKauF4HLKsfO NxPVKfSoqQYIZbixDOvA39r/jm3OqLqNRTfaw5cUJCj9r320VLe9MvBSiuhqyHh9Z6A== 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=TzumxUb7; 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 9461F606A335; Fri, 4 Dec 2026 11:10:27 +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=TzumxUb7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E6051F000C2; Fri, 4 Dec 2026 11:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382627; bh=QnBeBdhHkcMoFmPD0xHFtIOkbhETScdJLl7sOfz7Q1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TzumxUb7nFhh4DRYTZvNAWqmqtQf2BX6PTrQsCIEfjSo5B2ASwCsYRoio6AZp5Gl/ zUnTJlU15YBO5HfrVa0zzdPztw9kZuI8D8DjNUJnK8VU+eBz4qtKZg2UoU/iXP/Q7N iZaI0/rEVRpPe4NC9S48fUtd4pa/NpSxbEvR80Po= 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.18 498/703] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Date: Fri, 4 Dec 2026 19:06:37 +0900 Message-ID: <20261204100641.051023530@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 @@ -2280,8 +2280,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; @@ -2319,7 +2319,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;