]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/tls: fix kernel panic when alloc_page failed
authorPengtao He <hept.hept.hept@gmail.com>
Wed, 14 May 2025 13:20:13 +0000 (21:20 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 May 2025 14:40:51 +0000 (07:40 -0700)
We cannot set frag_list to NULL pointer when alloc_page failed.
It will be used in tls_strp_check_queue_ok when the next time
tls_strp_read_sock is called.

This is because we don't reset full_len in tls_strp_flush_anchor_copy()
so the recv path will try to continue handling the partial record
on the next call but we dettached the rcvq from the frag list.
Alternative fix would be to reset full_len.

Unable to handle kernel NULL pointer dereference
at virtual address 0000000000000028
 Call trace:
 tls_strp_check_rcv+0x128/0x27c
 tls_strp_data_ready+0x34/0x44
 tls_data_ready+0x3c/0x1f0
 tcp_data_ready+0x9c/0xe4
 tcp_data_queue+0xf6c/0x12d0
 tcp_rcv_established+0x52c/0x798

Fixes: 84c61fe1a75b ("tls: rx: do not use the standard strparser")
Signed-off-by: Pengtao He <hept.hept.hept@gmail.com>
Link: https://patch.msgid.link/20250514132013.17274-1-hept.hept.hept@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/tls/tls_strp.c

index 77e33e1e340e314fa285f0e7f235119e52a95a7a..65b0da6fdf6a79422200aecf5ca572da5ca57f04 100644 (file)
@@ -396,7 +396,6 @@ static int tls_strp_read_copy(struct tls_strparser *strp, bool qshort)
                return 0;
 
        shinfo = skb_shinfo(strp->anchor);
-       shinfo->frag_list = NULL;
 
        /* If we don't know the length go max plus page for cipher overhead */
        need_spc = strp->stm.full_len ?: TLS_MAX_PAYLOAD_SIZE + PAGE_SIZE;
@@ -412,6 +411,8 @@ static int tls_strp_read_copy(struct tls_strparser *strp, bool qshort)
                                   page, 0, 0);
        }
 
+       shinfo->frag_list = NULL;
+
        strp->copy_mode = 1;
        strp->stm.offset = 0;