Article View: linux.kernel.netdev
Article #17018Re: [PATCH V1 rdma-next 20/24] RDMA/mlx5: Clamp log_max_cq_sz shift in CQ size checks
From: Leon Romanovsky
Date: Mon, 16 Nov 2026 09:35
Date: Mon, 16 Nov 2026 09:35
40 lines
9176 bytes
9176 bytes
On Tue, Nov 10, 2026 at 03:43:16PM +0200, Yishai Hadas wrote:
> The CQ create and resize paths check the requested size against
> 1 << log_max_cq_sz. The cap is 8 bits wide, so an untrusted NIC can
> report 31 or more, which makes the shift undefined. A large limit also
> lets the rounded up CQ size exceed INT_MAX, and it is then truncated
> when passed on as an int.
>
> Such a size also overflows the CQ buffer size, entries * cqe_size,
> which create_cq_user() and alloc_cq_frag_buf() compute as an int. A
> user CQ buffer smaller than the CQ the NIC is given then passes the
> umem size check, and a kernel CQ gets a zero-sized buffer that
> init_cq_frag_buf() writes to.
>
> Take the limit from MLX5_CAP_GEN_LOGSZ_U64(), round up in 64 bits, and
> reject sizes above INT_MAX. Compute the buffer size with
> check_mul_overflow(), as resize_user() already does.
>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/infiniband/hw/mlx5/cq.c | 52 ++++++++++++++++++++++++---------
> 1 file changed, 39 insertions(+), 13 deletions(-)
<...>
> +/*
> + * Next power of 2 above entries. It can be 2^32, which doesn't fit the
> + * unsigned long of roundup_pow_of_two() on 32-bit archs.
This is not correct. unsigned long in the kernel continue to be 64bits
even for 32bits archs.
Thanks
> + */
> +static u64 cq_roundup_entries(u64 entries)
> +{
> + return 1ULL << fls64(entries);
> +}
> +
Technical Details
Message-ID:
<20261116093548.GE11319@unreal>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364144-linux-kernel-netdev=dewy.ruReferences:
<20261110134320.34408-1-yishaih@nvidia.com> <20261110134320.34408-21-yishaih@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364144-linux-kernel-netdev=dewy.ru From: leon@kernel.org (Leon Romanovsky) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH V1 rdma-next 20/24] RDMA/mlx5: Clamp log_max_cq_sz shift in CQ size checks Date: Mon, 16 Nov 2026 11:35:48 +0200 Organization: Usenet Network Message-ID: <20261116093548.GE11319@unreal> References: <20261110134320.34408-1-yishaih@nvidia.com> <20261110134320.34408-21-yishaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2022859"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:8tF8DakAgtZR6CiJYc3Iq+vELq4= sha256:dGqSpbkG4mlU/52dU2ylrTWe/Io82eeDGsc5PJELylQ= sha1:Zmxh568+Bpd26ofsMo3QMFR5W+I= sha256:WjvbIQDMCbIDEzZEGnMmiyAzoeisLCzi/X6mS2hbd74= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B3C08114B7C; Mon, 16 Nov 2026 12:36:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ji7-x8DMqsVk; Mon, 16 Nov 2026 12:36:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-364144-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id DB02C114B62; Mon, 16 Nov 2026 12:36:04 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id A4F9128D6A; Mon, 16 Nov 2026 09:35:58 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794821752; b=ZglR3o1y7P3QoNyHVJVZGhO1CqtP8EU7fuf0QqJwAjyWuy9Cr+5sqVELgRtDRKKKOP0B wFrEgKss9ld9SiHkgwW4XbamfxLo+IoEZG9dqxCOgH7I3k4ZLtwxcAGKgs5xi/IROUG1W sw99BOLz6R9w3kDIbffkMIH64xIAxRtY7p/yhKfgMQml8oNP3pDp2CmnIoKlqURsnV1Bz RIPGMqnbxi5/RKKIbFt3QN5URi7vZzBC4vE4WF9mwtjfHFpXU935/C3frN0bUKR80Tujc c7nHKb5LH4PcAfhHs9WQqjA0xHiuGPMbqvd40xqlZfHytdTj5TqX0K9zqJ7ew1g15cA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794821752; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=wU5BlvOSWQHWuUD3CMofjN5+zYIYJJVIozjcDpM3rSc=; b=47BWU9EtlUPPpW5Ke8QfNYYvcHzrRw/zgNtHq3O4UdoA86TJGf8MO/OIJ6p8ImLXDvPa lCjwvv8nD0j0gFxhgxoNfhVR0aSur8y6DBrKOopWnwJj2WRbUNkLhvLpgdXZ/SqAinkrG 8F9plEhxSerzJOpK5s3ac9oG3t6wzvUKte5qqTab5GS1QkSvct3NcEokahAE1ABHJsBXs M9+4OwqKopjT665kb4mwzp4RC+fGoWBu8negqqQSHeQpk9opdyMtTlIoPsSZ8s8jyfuZG 6YxJb2YqqfQYMIw7ZIOSDg+srp7gx1Fwvb7e4w2RSHw6ChGKjwWrudrukWbZYn+JxQw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0T4koTP; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B182E606A335; Mon, 16 Nov 2026 09:35:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0T4koTP X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794821751; b=0jbjGd5rCrnBivg154/Jojx7pgXUzig+KL7zFnJ+5TraDXc7GoK43BgCEzSu3aeQltss laRAYd7K07u7/R1KEx8VbFNqB9mk0uizfSQlmZY4Y8fflcUQs8jmDNuLYsxmCKena01tI YcPGG5vSkrMj2pd4oJ4jlzzaLqfwDSrwcYWbm8lfEK94AySbcmiaytLgxpyA/fNFBljkC QqSotS4DWE5H80KGQsKMt9ggieDNb1ewVBbFiPWKw63LYoARtUOhTYrXEG3DNAuwa8Izx rEdudZOP3reYqwy5Azv/cmDSLnrEmnubC6UtMk0fwLKEB4e+0kixsi9qeKa6xzaPwLg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794821751; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=wU5BlvOSWQHWuUD3CMofjN5+zYIYJJVIozjcDpM3rSc=; b=iSvUS+Iwlyx8FDVzg5Fsm9dFjQIqIs2bBWAxm9eXZMuQyicvuqya1wlRh73BGnwAiVHg +SWKuXMD4VN6NdzhmONhAh4z0alEu3hueAqnjq7K0QWD5vM1np+/EVE+giAY5GMf9XYpR gX9sU+uLy4ZoiefF7xn//ROdRnM5YDVSabKHXy5ZZmezCNO7RDI2p0HbgEYkfJd10Zdx6 789UdUdHoCRa1GtL3b5Ok/JQIiC2JUVw9vXRPln2quT2OhREr0XF9dYvqpHSyNAPIKMuH nKswfh6SBF04qr/lPOT7rWYN3IPi7afuqdJ+TvCEUlBJL/mxYFkK3amYzC5yMJG9eSQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0T4koTP; arc=none smtp.remote-ip=100.103.45.18 X-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 D3EE2606A899; Mon, 16 Nov 2026 09:35:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D9C11F00925; Mon, 16 Nov 2026 09:35:50 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794821751; bh=wU5BlvOSWQHWuUD3CMofjN5+zYIYJJVIozjcDpM3rSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=T0T4koTPiY7e4mXjHYi8Pwge+tWwQZBGA40k18ZIfwNT9H7+AQNKwi0Iz1/RPpqKn 6rE+2LIlKuXmScZSULIODOa9rzqAOQZX6uSSr5Pu5sMZDKRVEoeqGFfENViz6j1kJ2 IpFUq8KQ1BYLXT1/4ok4ct0X7EUsa24NvkkhjgjevhthBiMZuq3BF0aoTxWuLgCBe8 6utJSjluND8pK7Y4SubYdJNKwB29yEP1O8qNC+UoHI3VQP8P38CAa2R99T+ZNIJRA+ XjtPNClOji8YqtKhKfyZynY4BXKuWxktTBo6qi3Nx2r+wgmL5aJu8gu6itVZ9oYpwY 75N4qNH87y/YA== X-Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, davem@davemloft.net, andrew+netdev@lunn.ch, dtatulea@nvidia.com, moshe@nvidia.com, maorg@nvidia.com X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261110134320.34408-21-yishaih@nvidia.com>