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=1796383926; b=Pg+OgmbNfGle3eqZSKWjI3Q12WKv97Jp6YeHNxW4LM+C+7xpqFWn4HK/fKUre75V3i+i PCnkfavaM4x+8JFrCaej3QjLhvSiin9U/KDb6+coOAk+ekLl39CSvzoX5YI3MRlDK0JbH vtyXzZf5MFx//k4a0TGv+LA98Ewal6GZtjPquQvgXDpBY8DrgNArfZheQE01AdxZAOJau vyOPxHLO/QSe96++sK5xjl92T1lyjLpE4QHcy3yV8u9fw84/+vNj1a8vIdO8u8nuxVWqO 1iD4dqKh8Qxsme2CGVjYt6MZusxwX0KPT+B57XiyeBWjnpHBGOEJ2b2868NwFBumWqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383926; 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=wApyggPzuqkvnnz7DpU9nBLn9mxdQfRuUhYo/MXZMAg=; b=NBz0sdwv8Y1tFiyLxkEem6IKRfgng24p7RSf6Z9QRSq66TYLXguqkxG3I6YDnHvGZmsD iDD0pxyTJVZfe/SNifR67pLKbqW2DHsmB6ZfBaBHm67pJCzom+DZ7hbG1+n5BDrw5LDgj Mm7ZmW866TNyeSA0PDotfIYazOHgoeHF7nzf3xWhYzo1dV/FjNDJgVTLTKHHHSQHpDRCR YbQhhV93Nct5InO6PS2Aa9i0DOFtb7sKiJpMKvzjS4kiKaJdxGXARXleSlEASeIJZZsZU baZE8ea0Oo2nCTeb7JR5iEi3A/YywlFE4eDNl53ljLGgxBNJMKAgd1mqZdy/7old4Ng== 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="kw+Pxm/k"; 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 579BB606A6AE; Fri, 4 Dec 2026 11:32:06 +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=kw+Pxm/k Received: by smtp.kernel.org (Postfix) with ESMTPSA id 775FD1F0092C; Fri, 4 Dec 2026 11:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383925; bh=wApyggPzuqkvnnz7DpU9nBLn9mxdQfRuUhYo/MXZMAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kw+Pxm/kE9cDNa3qnmIUz0cPMNiZM3UQL4y2M6+rOxASICjNPeq6y/MSMfSw6Wv2W 0PxLzu1lYhEI4pveVYw5pnd8pUSs0b4RURUQ2rOOScH55c/frbdsGJV+G31O3EFRcP hWWwdNPchA/bhPeeMKqm9bNSNzWkBqts0s6Qf2l8= 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.12 426/555] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Date: Fri, 4 Dec 2026 19:07:49 +0900 Message-ID: <20261204100625.913094500@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 @@ -2232,8 +2232,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; @@ -2271,7 +2271,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;