tls: Use size_add() in call to struct_size()
Subsystems (3)
PATCH 1/1 tls: Use size_add() in call to struct_size()
If, for any reason, the open-coded arithmetic causes a wraparound, the protection that struct_size() adds against potential integer overflows is defeated. Fix this by hardening call to struct_size() with size_add().
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -1487,7 +1487,7 @@ static int tls_decrypt_sg(struct sock *sk, struct iov_iter *out_iov,*/ aead_size =sizeof (*aead_req) +crypto_aead_reqsize (ctx->aead_recv); aead_size = ALIGN(aead_size, __alignof__(*dctx)); - mem =kmalloc (aead_size +struct_size (dctx, sg, n_sgin + n_sgout), + mem =kmalloc (aead_size +struct_size (dctx, sg,size_add (n_sgin, n_sgout)), sk->sk_allocation);if (!mem) { err = -ENOMEM ;
Signature · 1 line
2.34.1
Quoted 7 lines · Gustavo A. R. Silva
If, for any reason, the open-coded arithmetic causes a wraparound, the protection that
struct_size()adds against potential integer overflows is defeated. Fix this by hardening call tostruct_size()withsize_add().Fixes b89fec54fd61 ("tls: rx: wrap decrypt params in a struct")Signed-off-by Gustavo A. R. Silva <[email protected]>
Signature · 1 line
Kees Cook
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 9 lines · On Fri, 15 Sep 2023 13:12:38 -0600 you wrote:
If, for any reason, the open-coded arithmetic causes a wraparound, the protection that
struct_size()adds against potential integer overflows is defeated. Fix this by hardening call tostruct_size()withsize_add().Fixes b89fec54fd61 ("tls: rx: wrap decrypt params in a struct")Signed-off-by Gustavo A. R. Silva <[email protected]>[...]
Here is the summary with links:
- [next] tls: Use size_add() in call to struct_size()
https://git.kernel.org/netdev/net-next/c/a2713257ee2b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html