Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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()`.

Fixes: b89fec54fd61 ("tls: rx: wrap decrypt params in a struct")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Gustavo A. R. Silva and committed by
David S. Miller
a2713257 e22c6ea0

+1 -1
+1 -1
net/tls/tls_sw.c
··· 1487 1487 */ 1488 1488 aead_size = sizeof(*aead_req) + crypto_aead_reqsize(ctx->aead_recv); 1489 1489 aead_size = ALIGN(aead_size, __alignof__(*dctx)); 1490 - mem = kmalloc(aead_size + struct_size(dctx, sg, n_sgin + n_sgout), 1490 + mem = kmalloc(aead_size + struct_size(dctx, sg, size_add(n_sgin, n_sgout)), 1491 1491 sk->sk_allocation); 1492 1492 if (!mem) { 1493 1493 err = -ENOMEM;