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 DBC4525E81F; Tue, 11 Mar 2025 15:05:09 +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=1741705509; cv=none; b=lFGAZ5hr6AKm0PgShUnDyB6ZpICuBZFsKRyzwAUiOZJaro1O6SYwOJiVOyAF900hbguh/04VEuBGdE9frC7QH742I3OuVCYzojh+IC+zPEYUHEC2tkXPEQVk33GwqBCHJXmqFTjE923llDME+crcwav3D/onxLSLwGsApB6CogQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741705509; c=relaxed/simple; bh=976mh0w/3km6I9eYvW+8w0PU0/esEwmw+4t9fL0BaD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxRaMf8ktUTlaz4xlpkq37sLFNy7pALd2O5LZjhxCmZtjC05cVlJDR9qat8Dohu6MLQUVyUYNDn36BqlduI3OBwBrJZ6Bkai/6RxqGoJaPEgUPYo9lon+2RNuJEPKghjjFXW4qKQWsN7NQ/hcLPrAmPq3BKYHdBpgqqFwaFuPSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hhHHiZmk; 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="hhHHiZmk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6407DC4CEEA; Tue, 11 Mar 2025 15:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741705509; bh=976mh0w/3km6I9eYvW+8w0PU0/esEwmw+4t9fL0BaD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhHHiZmkDDdpWnNJKQ52eEA1zo5D8mfoSg8/ZWEDnXvBPCMwMpoLmt62aOVnmBfki 5hh0qcg9orjq5Mm+7SFPlopykkdXyyvEWq3d2UQkmCUm2hleM4kIPB/cMxTtAugxOe qJDAb0QX0qOS5hp/4OJUzsB42lb+uQPN8OTpAE04= 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 5.4 043/328] rdma/cxgb4: Prevent potential integer overflow on 32bit Date: Tue, 11 Mar 2025 15:56:53 +0100 Message-ID: <20250311145716.605146897@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311145714.865727435@linuxfoundation.org> References: <20250311145714.865727435@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 5.4-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 541dbcf22d0eb..13e4b2c40d835 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