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=1796381108; b=A4fzAR7DnTaGyxB3KaEvQABT3l0VDh6hsJl172ndTsFbWRFBtt1vJLC3qvXGmmTKMwzo /Tw9OyXU7ku2jRbHUHXYzI+gps4QdA6E8snSYcLYuS5EZtWhvR7at2aTU0Tfg3SKhH9Mc iKqSbQR+tICDn1HoycK+eGla5dDS/lc6uwovvMq0NiYt5hX50/U27PEOazZRLAE5uWIDv D4lWkcN7EsryXjbknvhOBi5R9stgNNiJAY6db3NFdWP7XvCp7XKDQe+ZuZavxXETRmwtu OmdEVMe5X2HCovqONn0n8oIlTT3QKfMSrgEhkYzYynRY/Vi1vVfFN4kbEGenrGIXpjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381108; 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=x/DlQGmOP932drpWSujCRB9kPm23oE/FiJrlhpXqoSU=; b=G0xTCTwBeEijVxdSmq9nOR/ZxfWmkt+QxykrcUlSIH8ykngd1ogn1nzwfjIM4dQ7rC7i zcpY6DJpCEkcYNWeCx3KYZ/bjJPPpepZyVGPcyTzLkE1v1bmew+WwdVPztXqczUv0El0X syB0AINrtaqrmaTQXI2etJ+HM/QhkjchNd7SXiwQVadOq8+iuNGugoJ9ZK6G8v2VQA0j+ uB04uai4oARbjKEOu5EuNPpwd91mKetD0+msQvc53VGYGgujSJt+g+DOvmn8RTYTIifNi uqVFWKsj+1lyfyCtRI+OYwR4d643dj6Ax4Nh3vnIwoVfSTAfeb8JjZ2U8WXxQwdNePw== 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=d6PE7kqr; 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 AA537606A33B; Fri, 4 Dec 2026 10:45:08 +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=d6PE7kqr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25F131F00A0E; Fri, 4 Dec 2026 10:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381108; bh=x/DlQGmOP932drpWSujCRB9kPm23oE/FiJrlhpXqoSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d6PE7kqrdtMlLnKSLFwBmhHHIfUX8Lp34DsTc51EwSfzbVbv8clynpWQqBcOehHwF FFob8OHPM8OVT2MT4E0mxsXgOPNy05jCVrGy1UE4nxqMxE5YlX4PWSKOx+gE4fX4nA G6zw+fndX9AOk642S3Q+DjVYfkZZRLCH5qOd+4y4= 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 7.3 561/742] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Date: Fri, 4 Dec 2026 19:07:05 +0900 Message-ID: <20261204100650.051733494@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -2294,8 +2294,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; @@ -2333,7 +2333,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;