Descripción
En el kernel de Linux, se resolvió la siguiente vulnerabilidad: tcp: do not coalesce segments after FIN Un FIN consume un número de secuencia. Si otro segmento FIN se fusiona en un skb que ya lleva FIN, end_seq avanza para contabilizar el FIN adicional, pero tcp_flags sigue conteniendo solo un bit FIN. Cuando se llena el hueco anterior y tcp_ofo_queue() procesa el skb fusionado, rcv_nxt avanza hasta el end_seq del skb. Cuando la ruta de recepción consume todos los datos del skb, copied_seq avanza según la longitud de los datos más un número de secuencia por el FIN. Si tres o más segmentos FIN se han fusionado en un skb, tcp_inq() todavía puede devolver un valor positivo después de que la cola de recepción queda vacía y se aplica el ajuste SOCK_DONE. TCP_ZEROCOPY_RECEIVE es otro consumidor afectado por este estado. tcp_zerocopy_receive() toma su longitud de tcp_inq() y sigue skb->next sin verificar el fin de la cola de recepción. La recepción kTLS por software es uno de los consumidores afectados por este estado. Cuando strp->copy_mode es false, tls_strp_msg_consume() llama a la función auxiliar TCP tcp_read_done() para consumir el registro TLS actual. En el reproductor, tcp_read_done() consumió los datos del registro y un FIN antes de liberar el skb de recepción. Cuando kTLS buscó el siguiente registro, tcp_inq() informó al menos TLS_HEADER_SIZE bytes aunque la cola de recepción estaba vacía. tcp_recv_skb() devolvió NULL, por lo que tls_strp_load_anchor_with_queue() activó WARN_ON_ONCE() y retornó sin actualizar el anchor. Como tcp_inq() había informado al menos TLS_HEADER_SIZE, tls_strp_read_sock() continuó hacia tls_strp_check_queue_ok(). skb_shinfo(strp->anchor)->frag_list todavía apuntaba al skb de recepción liberado. tls_strp_check_queue_ok() leyó entonces TCP_SKB_CB(first)->seq a través del puntero obsoleto, lo que provocó un uso después de liberar memoria (use-after-free). El reproductor siguió esta ruta de llamadas: tls_rx_rec_done() tls_strp_msg_consume() tcp_read_done() // libera el skb de recepción tls_strp_check_rcv() tls_strp_read_sock() tls_strp_load_anchor_with_queue() // retorna después de WARN_ON_ONCE() tcp_recv_skb() == NULL tls_strp_check_queue_ok() TCP_SKB_CB(first)->seq // lee el skb de recepción liberado KASAN informó: BUG: KASAN: slab-use-after-free in tls_strp_check_queue_ok.isra.0+0x5f/0x100 Read of size 4 at addr ffff888103169ca8 by task ktls-server/71 ... Call Trace: <TASK> ... tls_strp_check_queue_ok.isra.0+0x5f/0x100 tls_strp_check_rcv+0x2a9/0x400 ... tls_sw_recvmsg+0x3ce/0xa10 ... sock_recvmsg+0xea/0x100 __sys_recvfrom+0x142/0x1f0 ... __x64_sys_recvfrom+0x76/0x90 do_syscall_64+0xdd/0x4a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f ... </TASK> ... Freed by task 71: ... napi_skb_cache_put+0x24/0xf0 skb_attempt_defer_free+0x183/0x3b0 tcp_read_done+0x2d4/0x340 tls_strp_msg_consume+0x45/0x80 tls_sw_recvmsg+0x3c4/0xa10 ... En tcp_try_coalesce(), se omite la fusión cuando el skb de destino ya lleva FIN. tcp_add_backlog() llama directamente a skb_try_coalesce() en lugar de usar esta función auxiliar, por lo que se agrega la misma verificación allí. Como ambas rutas verifican solo el skb de destino, un segmento final que lleve datos y FIN todavía puede fusionarse en un skb sin FIN cuando se cumplen las demás verificaciones de fusión.
Qué hacer
Revisa si usas el producto afectado y en qué versión, y aplica la actualización o la mitigación que indique el aviso del fabricante. CISA no ha confirmado que se esté explotando; si eso cambia, esta ficha pasa a «explotada» y te avisamos en el boletín.
Versiones afectadas
- Linux Afectadas: e93a0435f809d009919a743fb6e93076faac8aa7 y anteriores a 0fad9b99568afaf017a545302abca2b4b36b319b · e93a0435f809d009919a743fb6e93076faac8aa7 y anteriores a c9484616ef9b00343bb880b1f11100822b877b3e · e93a0435f809d009919a743fb6e93076faac8aa7 y anteriores a 1c46780dec48893b8c25fd5e33a3127e8dc39dd4
- Linux Afectadas: 3.18 No afectadas: 6.18.66 · 7.3.7 · 7.4-rc3
Según el registro de la vulnerabilidad en CVE.org, tal como lo publicó el fabricante. Confirma tu versión exacta en el aviso del fabricante.
Referencias
- Referencia en git.kernel.orggit.kernel.org/stable/c/0fad9b99568afaf017a545302abca2b4b36b319b
- Referencia en git.kernel.orggit.kernel.org/stable/c/c9484616ef9b00343bb880b1f11100822b877b3e
- Referencia en git.kernel.orggit.kernel.org/stable/c/1c46780dec48893b8c25fd5e33a3127e8dc39dd4
Ver el texto original en inglés (CVE.org)
tcp: do not coalesce segments after FIN
In the Linux kernel, the following vulnerability has been resolved: tcp: do not coalesce segments after FIN A FIN consumes a sequence number. If another FIN segment is coalesced into an skb that already carries FIN, end_seq advances to account for the additional FIN, but tcp_flags still contains only one FIN bit. When the preceding gap is filled and tcp_ofo_queue() processes the coalesced skb, rcv_nxt advances to the skb's end_seq. When the receive path consumes all data in the skb, copied_seq advances by the data length and one sequence number for FIN. If three or more FIN segments have been coalesced into one skb, tcp_inq() can still return a positive value after the receive queue becomes empty and the SOCK_DONE adjustment is applied. TCP_ZEROCOPY_RECEIVE is another consumer affected by this state. tcp_zerocopy_receive() takes its length from tcp_inq() and follows skb->next without checking for the end of the receive queue. Software kTLS receive is one consumer affected by this state. When strp->copy_mode is false, tls_strp_msg_consume() calls the TCP helper tcp_read_done() to consume the current TLS record. In the reproducer, tcp_read_done() consumed the record data and one FIN before freeing the receive skb. When kTLS looked for the next record, tcp_inq() reported at least TLS_HEADER_SIZE bytes even though the receive queue was empty. tcp_recv_skb() returned NULL, so tls_strp_load_anchor_with_queue() hit WARN_ON_ONCE() and returned without updating the anchor. Since tcp_inq() had reported at least TLS_HEADER_SIZE, tls_strp_read_sock() proceeded to tls_strp_check_queue_ok(). skb_shinfo(strp->anchor)->frag_list still pointed to the freed receive skb. tls_strp_check_queue_ok() then read TCP_SKB_CB(first)->seq through the stale pointer, causing a use-after-free. The reproducer followed this call path: tls_rx_rec_done() tls_strp_msg_consume() tcp_read_done() // frees the receive skb tls_strp_check_rcv() tls_strp_read_sock() tls_strp_load_anchor_with_queue() // returns after WARN_ON_ONCE() tcp_recv_skb() == NULL tls_strp_check_queue_ok() TCP_SKB_CB(first)->seq // reads the freed receive skb KASAN reported: BUG: KASAN: slab-use-after-free in tls_strp_check_queue_ok.isra.0+0x5f/0x100 Read of size 4 at addr ffff888103169ca8 by task ktls-server/71 ... Call Trace: <TASK> ... tls_strp_check_queue_ok.isra.0+0x5f/0x100 tls_strp_check_rcv+0x2a9/0x400 ... tls_sw_recvmsg+0x3ce/0xa10 ... sock_recvmsg+0xea/0x100 __sys_recvfrom+0x142/0x1f0 ... __x64_sys_recvfrom+0x76/0x90 do_syscall_64+0xdd/0x4a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f ... </TASK> ... Freed by task 71: ... napi_skb_cache_put+0x24/0xf0 skb_attempt_defer_free+0x183/0x3b0 tcp_read_done+0x2d4/0x340 tls_strp_msg_consume+0x45/0x80 tls_sw_recvmsg+0x3c4/0xa10 ... In tcp_try_coalesce(), skip coalescing when the destination skb already carries FIN. tcp_add_backlog() calls skb_try_coalesce() directly instead of using this helper, so add the same check there. Since both paths check only the destination skb, a final segment carrying data and FIN can still be coalesced into an skb without FIN when the other coalescing checks pass.