Skip to contentSkip to conversation

chelsio/chtls: prevent potential integer overflow on 32bit

PATCH Applied Dan Carpenter 3 participants 3 messages Dec 13, 2024 – Dec 17, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chelsio/chtls: prevent potential integer overflow on 32bit

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 a08943947873 ("crypto: chtls - Register chtls with net tls")

---
I fixed a similar bug earlier:
https://lore.kernel.org/all/[email protected]

 .../net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c +3 -2
index 96fd31d75dfd..daa1ebaef511 100644
@@ -346,8 +346,9 @@ static struct sk_buff *copy_gl_to_skb_pkt(const struct pkt_gl *gl,
 	 * driver. Once driver synthesizes cpl_pass_accept_req the skb will go
 	 * through the regular cpl_pass_accept_req processing in TOM.
 	 */
-	skb = alloc_skb(gl->tot_len + sizeof(struct cpl_pass_accept_req)
-			- pktshift, GFP_ATOMIC);
+	skb = alloc_skb(size_add(gl->tot_len,
+				 sizeof(struct cpl_pass_accept_req)) -
+			pktshift, GFP_ATOMIC);
 	if (unlikely(!skb))
 		return NULL;
 	__skb_put(skb, gl->tot_len + sizeof(struct cpl_pass_accept_req)
Signature · 1 line
2.45.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dan Carpenter

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 a08943947873 ("crypto: chtls - Register chtls with net tls")

---
I fixed a similar bug earlier:
https://lore.kernel.org/all/[email protected]

Thanks Dan,

#2 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 13 Dec 2024 12:47:27 +0300 you wrote:

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 a08943947873 ("crypto: chtls - Register chtls with net tls")

[...]

Here is the summary with links:
- [net] chelsio/chtls: prevent potential integer overflow on 32bit

    https://git.kernel.org/netdev/net/c/fbbd84af6ba7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html