Patch "tls: Use size_add() in call to struct_size()" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tls: Use size_add() in call to struct_size()

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tls-use-size_add-in-call-to-struct_size.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4c589c6cd25dc5972d336e00964bf9fc236f1b26
Author: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
Date:   Fri Sep 15 13:12:38 2023 -0600

    tls: Use size_add() in call to struct_size()
    
    [ Upstream commit a2713257ee2be22827d7bc248302d408c91bfb95 ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index ce925f3a52492..57e4601eaaf50 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -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 = 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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux