From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793813922; b=hglVZpIirpdBdj+4Y6ZxUtIwvRjoAH8Ad+HGnqCo5d4Bf2a96kBVWCqsL1ZF7meNzPw7 A3SyPnb4WgBUH4jhfE3RKcqYvrme7VUFwKlBDmhYt1hYWxzEscn8BzwpPWjXvyIieZWPX VDVW0z/aZhzLr/7IN21g6p2XTiKc8x8/VLT7Al8n46NXungpNFY5AKSCXKed4nOwnP5Is uo5XF92EBULUIu3mvzJowpRGb8X6DuBnBAC1ahOhpCk3A0RUuROGL0GTX79fd4bPURL6G QbBGPJjktK6Yuf66t4T1DtCwUvxTbkcs8JaOGHqVD4hfi2xmNsZhtUY/J36zA49TdpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793813922; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=yl3p6kivD+pbgaW7MJkK3w3sK9j5Q+Oatf9YNzkPHuQ=; b=UyrTxCZicaN0c8EfnCsPc2Iio9SSsW94tLbTYc5BcpyVywrYGGfnv/jEiRCLQ/snVuXS avO2lRZ8GEyyxNOTLbBR0RgjF2OaGrZuhr4feFL5d3YrAwpsUf2FAqmBuQ0lwGxZI5Rsk cTMCJ8/x4h0M0re08sbGDcwQr+Gxzlr/a7L1j21cirRpW8qjGTM+pdtOZcHh9E+7xjA8K hVksdzM9MlZolO6/zJ/Tn1mldwHxpf1VugfimqQMuXxRwgLzwdfTb+T5h60+Aybkx71W/ BloTzGjQJsl+pCjoVDCmtXETXUMUpuTphtl+ugmeo2rw1BJ26wJ5vnZyUBrCXYsDhTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=mrY8ROdm; arc=none smtp.remote-ip=209.85.222.172 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CC1D606A330 for ; Wed, 4 Nov 2026 17:38:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2CC1D606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=mrY8ROdm Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-93a40a9a01aso256023585a.0 for ; Wed, 04 Nov 2026 09:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1793813921; x=1794418721; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yl3p6kivD+pbgaW7MJkK3w3sK9j5Q+Oatf9YNzkPHuQ=; b=mrY8ROdmQ1U8qG1WVkHwFlUc3uGFi+mfdwhSWPL3i9Jp9h8f89iHmTdDBHaGoSb9fV Qf9rVp7RKUT19nXLbySXsX1HX9ejTq1RkMbi9uctb50nDdYeaJxGrg0TKGC3n5LuHDCN s/MNCqdyz7OsSy5/Xj4hUz7Xx9K8J+nT+Rgtz/TEx7hQSBym/uHrT0083IL7OdGOVSoW QWTluEuJP2tc6R56IYPlBHffsnVWwQA6M5o6QgL6HcwG3w2leCaMPqVjEYBQupV7hAqq SD6IF6/nTL+K1g1CWe1MCWd4YJ9zVV8/dLg6SmJyJNXdrhSgMr1A+M+/81J0lXd5xQmn obNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793813921; x=1794418721; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yl3p6kivD+pbgaW7MJkK3w3sK9j5Q+Oatf9YNzkPHuQ=; b=evccE/DqCQ0M51TeNRaEeqRMZPY0RxfOaoXMrRMzFQO2DKHb5j2tQWsGfBfsPrjtAD HvwR2zN+cNGtqpPaB4J6Pmqnx/V8SNVXQUi5htC42FLm5QLr+zDZiZUD5LEVoBlHB/zW v2KBjAc+NU8dKeHC1vn0V+eXbbO68y1Df2YhqFxKiBnhhpnnHCTIc0Rxhwx05aKJsUxj XfkcBfleIQuvv+2Hac99R0O9DWZiSpAwn5I+B3meFRRi+6byS+ys3icS5hen49UJK4Xv qzKOiV1xdy40QVnXlF+gw4bUnxodNS0s7JYGIQDVx+aB8DdMy3GsKT5yMOdmfbLMYYgf NyBA== X-Forwarded-Encrypted: i=1; AKwUvBxYZTCNBE2xbEPof20PziP43Md+YWa+VcASvPYhmD2lauLmKULxVmp0ACOfsxXhHaeuWE+WtMw=@vger.kernel.org X-Gm-Message-State: APuU4Z80g+LnSPniCve9U7gkF8RPMH1IlDU8N7Yng443bjQU+e2EPx/C gRufoPgCeWtQAbtTQePepOHDFcNL1RaPkeIfa5ByL8s0hWO6VMHVBBFjZu33slvqZDQ= X-Gm-Gg: AYBFou2f+opka7Y68UaGnO5rbWSbOfRRKoTgU9MQuCXk4FyEjimKw5Q1HxU3pztW6EL pljdpOXI4nU1vHwYUWkYPD2jDpLuFtij2XaO7CI2WrCe7bZYrmef82nYnu4FGIrMcotMya48vnT HgZ+W61Nd3tscb7SWQhhCSliiTJ9rk4DaEKeHX9W51IG8yuzGPYFcF22+G/mAh+aCWX0l1JyBzM 4O0TKDcn2+6+6UDZFA/XU1w/55c/vmcjbJ6LCI7TeG/3GtSoMKJlCqbJ+16TM3yFclbTYFURNVE EyiUxilAmbKlEPnhw3Ajhh9m01yfVp9PhHOurvZRzcfmzT4akLPxqcBXdta5vYKcW32DWUAhLiL 1G+eg2mePQC8yVV/WKkiL2CltgLLBzUDGlVTjHSGQcyPEYjtBOqbTIpbX4WLe+32gcYLSKibKmF 7j87b4lxtIarChILu/265gb91a0eisDYcNc4HcI+sb6SBihWmon5ktszZdefctdXyONxkTiaXeu dYdsj07EPCB+AQpZ090uI19W7/kpNkhBTA7hc0y5Y1Yf5ThvcN/kFdPvDGzp2J6Zz97SGDrAwBc th225w6uq/jJ0R9U9fHTG6yeE5P84mR3D+uy1sshFgquRw9AFjGf6uPTnsUkKtvKS5uQ7Q8oUCR dfLSNNtWm1Q== X-Received: by 2002:a05:620a:258b:b0:93c:3863:ff7f with SMTP id af79cd13be357-945e1231638mr47030585a.0.1793813921165; Wed, 04 Nov 2026 09:38:41 -0800 (PST) Received: from ziepe.ca (hlfxns010zw-159-2-239-150.pppoe-dynamic.high-speed.ns.bellaliant.net. [159.2.239.150]) by smtp.gmail.com with ESMTPSA id af79cd13be357-945d479ddb7sm249464685a.9.2026.11.04.09.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 09:38:40 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1xOewa-0000000Gz0A-0aRN; Wed, 04 Nov 2026 13:38:40 -0400 Date: Wed, 4 Nov 2026 13:38:40 -0400 From: Jason Gunthorpe To: 0z5a Cc: leon@kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH rdma-rc] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Message-ID: <20261104173840.GX3889730@ziepe.ca> References: <20261103142804.67210-1-dezhen.lu@student.uni-tuebingen.de> 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261103142804.67210-1-dezhen.lu@student.uni-tuebingen.de> On Tue, Nov 03, 2026 at 03:28:04PM +0100, 0z5a wrote: > From: Dezhen Lu > > 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 > --- Reviewed-by: Jason Gunthorpe > - So I have not verified that CREATE_UMEM accepts log_page_size values > for pages >= 4 GiB. If it does not, capping pgsz_bitmap at 2^31 in > devx_umem_find_best_pgsize() is the alternative fix. It is userspace's problem to provide a correct bitmap in MLX5_IB_ATTR_DEVX_UMEM_REG_PGSZ_BITMAP for whatever it is doing. FW can reject large sizes outside what it supports if userspace sends the incorrect bitmap. Jason