From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A202E1519AA; Wed, 5 Feb 2025 14:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738764788; cv=none; b=oyvR0HIoTWgcu5uA2F5VjSZwBbQ5lkeqQPLkmb1exdzf5ImUS5J/dn46yBcqkSwrmHTytEPoajyC2WuIQZhqrw2L0dERwlPH5jvZ81OVjBKE/D6CZojWdUoVndHOL4yBlobhTNWcioq1nxODUT2MBaxEeMJrHPo4OIQA/ffoLNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738764788; c=relaxed/simple; bh=ji4HZjwaHv8uBbjyD6QIU0qaDKGecF3H37XkUiB4mOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O0fhz10GoXMyAyFmFePRwkkQmKrAqonSob9CYLVzXE8/qfQ61U8WCPRW9+CyvnHUqEBKSiqYGNadj3LUhnbImm9Yk0Qcd3ZhASln1EBrifLhArK4HF7iFwMIVPFk/HcKHxtWxBeqHqbfCeQQt0wI9uRkFSr3UDruHMpJyY2rOjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ct4Dix3u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ct4Dix3u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04FE1C4CED1; Wed, 5 Feb 2025 14:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738764788; bh=ji4HZjwaHv8uBbjyD6QIU0qaDKGecF3H37XkUiB4mOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ct4Dix3uTU6+GS4TQUMVAmrV5+9WonkJonIfzNy6fd4eJ+f7X5jr2z6CbBgXRBuem ZWfOE68WANjZGVksGXxELwRtUCibYk/YFPtQ8J3fJaommM26d3OvozkxbBRA8m4LV5 ewnEl7rnTkInvyRDGXqmoWrMUwj1VwgorJ4W4lgc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Jason Gunthorpe , Sasha Levin Subject: [PATCH 6.6 204/393] rdma/cxgb4: Prevent potential integer overflow on 32bit Date: Wed, 5 Feb 2025 14:42:03 +0100 Message-ID: <20250205134428.110507477@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134420.279368572@linuxfoundation.org> References: <20250205134420.279368572@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit bd96a3935e89486304461a21752f824fc25e0f0b ] The "gl->tot_len" variable is controlled by the user. It comes from process_responses(). On 32bit systems, the "gl->tot_len + sizeof(struct cpl_pass_accept_req) + sizeof(struct rss_header)" addition could have an integer wrapping bug. Use size_add() to prevent this. Fixes: 1cab775c3e75 ("RDMA/cxgb4: Fix LE hash collision bug for passive open connection") Link: https://patch.msgid.link/r/86b404e1-4a75-4a35-a34e-e3054fa554c7@stanley.mountain Signed-off-by: Dan Carpenter Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/cxgb4/device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index 80970a1738f8a..034b85c422555 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c @@ -1114,8 +1114,10 @@ static inline struct sk_buff *copy_gl_to_skb_pkt(const struct pkt_gl *gl, * The math here assumes sizeof cpl_pass_accept_req >= sizeof * cpl_rx_pkt. */ - skb = alloc_skb(gl->tot_len + sizeof(struct cpl_pass_accept_req) + - sizeof(struct rss_header) - pktshift, GFP_ATOMIC); + skb = alloc_skb(size_add(gl->tot_len, + sizeof(struct cpl_pass_accept_req) + + sizeof(struct rss_header)) - pktshift, + GFP_ATOMIC); if (unlikely(!skb)) return NULL; -- 2.39.5