mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
tls: Use size_add() in call to struct_size()
[ Upstream commita2713257ee
] 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:b89fec54fd
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d648260e44
commit
7c13d9cce8
|
@ -1488,7 +1488,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 = sizeof(*aead_req) + crypto_aead_reqsize(ctx->aead_recv);
|
||||||
aead_size = ALIGN(aead_size, __alignof__(*dctx));
|
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);
|
sk->sk_allocation);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user