CVE-2023-52523
JSON

7.8high

bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets

Severity
7.8high CVSS:3.1 by Linux
Exploit likelihood
0.24% (higher than 15% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets With a SOCKMAP/SOCKHASH map and an sk_msg program user can steer messages sent from one TCP socket (s1) to actually egress from another TCP socket (s2): tcp_bpf_sendmsg(s1) // = sk_prot->sendmsg tcp_bpf_send_verdict(s1) // __SK_REDIRECT case tcp_bpf_sendmsg_redir(s2) tcp_bpf_push_locked(s2) tcp_bpf_push(s2) tcp_rate_check_app_limited(s2) // expects tcp_sock tcp_sendmsg_locked(s2) // ditto There is a hard-coded assumption in the call-chain, that the egress socket (s2) is a TCP socket. However in commit 122e6c79efe1 ("sock_map: Update sock type checks for UDP") we have enabled redirects to non-TCP sockets. This was done for the sake of BPF sk_skb programs. There was no indention to support sk_msg send-to-egress use case. As a result, attempts to send-to-egress through a non-TCP socket lead to a crash due to invalid downcast from sock to tcp_sock: BUG: kernel NULL pointer dereference, address: 000000000000002f ... Call Trace: <TASK> ? show_regs+0x60/0x70 ? __die+0x1f/0x70 ? page_fault_oops+0x80/0x160 ? do_user_addr_fault+0x2d7/0x800 ? rcu_is_watching+0x11/0x50 ? exc_page_fault+0x70/0x1c0 ? asm_exc_page_fault+0x27/0x30 ? tcp_tso_segs+0x14/0xa0 tcp_write_xmit+0x67/0xce0 __tcp_push_pending_frames+0x32/0xf0 tcp_push+0x107/0x140 tcp_sendmsg_locked+0x99f/0xbb0 tcp_bpf_push+0x19d/0x3a0 tcp_bpf_sendmsg_redir+0x55/0xd0 tcp_bpf_send_verdict+0x407/0x550 tcp_bpf_sendmsg+0x1a1/0x390 inet_sendmsg+0x6a/0x70 sock_sendmsg+0x9d/0xc0 ? sockfd_lookup_light+0x12/0x80 __sys_sendto+0x10e/0x160 ? syscall_enter_from_user_mode+0x20/0x60 ? __this_cpu_preempt_check+0x13/0x20 ? lockdep_hardirqs_on+0x82/0x110 __x64_sys_sendto+0x1f/0x30 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd Reject selecting a non-TCP sockets as redirect target from a BPF sk_msg program to prevent the crash. When attempted, user will receive an EACCES error from send/sendto/sendmsg() syscall.

Affected

Product or packageVersionsReported by
Linux Linuxfrom 122e6c79efe1c25816118aca9cfabe54e99c2432 before bc8b89b6963803a123f64aa9494155a037b3d728, from 122e6c79efe1c25816118aca9cfabe54e99c2432 before b8f97e47b6fb84fcf2f5a22e725eefb6cf5070c2, from 122e6c79efe1c25816118aca9cfabe54e99c2432 before ded6e448028f0f91b6af35985afca01fa02a9089, from 122e6c79efe1c25816118aca9cfabe54e99c2432 before b80e31baa43614e086a9d29dc1151932b1bd7fc5, 5.13
Not affected: before 5.13, from 5.15.135 up to 5.15.*, from 6.1.57 up to 6.1.*, from 6.5.7 up to 6.5.*, from 6.6 up to *
CVE List
linux linux_kernelfrom 5.13 before 5.15.135, from 5.16 before 6.1.57, from 6.2 before 6.5.7, 6.6NVD

All scores

Linux7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD5.5medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-476

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets With a SOCKMAP/SOCKHASH map and an sk_msg program user can steer messages sent from one TCP socket (s1) to actually egress from another TCP socket (s2): tcp_bpf_sendmsg(s1) // = sk_prot->sendmsg tcp_bpf_send_verdict(s1) // __SK_REDIRECT case tcp_bpf_sendmsg_redir(s2) tcp_bpf_push_locked(s2) tcp_bpf_push(s2) tcp_rate_check_app_limited(s2) // expects tcp_sock tcp_sendmsg_locked(s2) // ditto There is a hard-coded assumption in the call-chain, that the egress socket (s2) is a TCP socket. However in commit 122e6c79efe1 ("sock_map: Update sock type checks for UDP") we have enabled redirects to non-TCP sockets. This was done for the sake of BPF sk_skb programs. There was no indention to support sk_msg send-to-egress use case. As a result, attempts to send-to-egress through a non-TCP socket lead to a crash due to invalid downcast from sock to tcp_sock: BUG: kernel NULL pointer dereference, address: 000000000000002f ... Call Trace: <TASK> ? show_regs+0x60/0x70 ? __die+0x1f/0x70 ? page_fault_oops+0x80/0x160 ? do_user_addr_fault+0x2d7/0x800 ? rcu_is_watching+0x11/0x50 ? exc_page_fault+0x70/0x1c0 ? asm_exc_page_fault+0x27/0x30 ? tcp_tso_segs+0x14/0xa0 tcp_write_xmit+0x67/0xce0 __tcp_push_pending_frames+0x32/0xf0 tcp_push+0x107/0x140 tcp_sendmsg_locked+0x99f/0xbb0 tcp_bpf_push+0x19d/0x3a0 tcp_bpf_sendmsg_redir+0x55/0xd0 tcp_bpf_send_verdict+0x407/0x550 tcp_bpf_sendmsg+0x1a1/0x390 inet_sendmsg+0x6a/0x70 sock_sendmsg+0x9d/0xc0 ? sockfd_lookup_light+0x12/0x80 __sys_sendto+0x10e/0x160 ? syscall_enter_from_user_mode+0x20/0x60 ? __this_cpu_preempt_check+0x13/0x20 ? lockdep_hardirqs_on+0x82/0x110 __x64_sys_sendto+0x1f/0x30 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd Reject selecting a non-TCP sockets as redirect target from a BPF sk_msg program to prevent the crash. When attempted, user will receive an EACCES error from send/sendto/sendmsg() syscall.

NVD (es)

En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpf, sockmap: rechaza las redirecciones de salida de sk_msg a sockets que no son TCP. Con un mapa SOCKMAP/SOCKHASH y un programa sk_msg, el usuario puede dirigir los mensajes enviados desde un socket TCP (s1) para que realmente salgan desde otro socket TCP (s2): tcp_bpf_sendmsg(s1) // = sk_prot-&gt;sendmsg tcp_bpf_send_verdict(s1) // __SK_REDIRECT caso tcp_bpf_sendmsg_redir(s2) tcp_bpf_push_locked(s2) tcp_bpf_push(s2) tcp_rate_check_ app_limited(s2) // espera tcp_sock tcp_sendmsg_locked(s2 ) // ídem Hay una suposición codificada en la cadena de llamadas de que el socket de salida (s2) es un socket TCP. Sin embargo, en el commit 122e6c79efe1 ("sock_map: Actualizar comprobaciones de tipo de calcetín para UDP") hemos habilitado redirecciones a sockets que no son TCP. Esto se hizo por el bien de los programas BPF sk_skb. No había ninguna sangría para admitir el caso de uso de envío a salida de sk_msg. Como resultado, los intentos de envío a salida a través de un socket que no es TCP provocan un bloqueo debido a una conversión no válida de sock a tcp_sock: ERROR: desreferencia del puntero NULL del núcleo, dirección: 0000000000000002f... Seguimiento de llamadas: . mostrar_regs+0x60/0x70? __die+0x1f/0x70 ? page_fault_oops+0x80/0x160? do_user_addr_fault+0x2d7/0x800? rcu_is_watching+0x11/0x50? exc_page_fault+0x70/0x1c0? asm_exc_page_fault+0x27/0x30? tcp_tso_segs+0x14/0xa0 tcp_write_xmit+0x67/0xce0 __tcp_push_pending_frames+0x32/0xf0 tcp_push+0x107/0x140 tcp_sendmsg_locked+0x99f/0xbb0 tcp_bpf_push+0x19d/0x3a0 tcp_bpf_sendmsg_redir+0x55/0xd0 tcp_bpf_send_verdict+0x407/0x550 tcp_bpf_sendmsg+0x1a1/0x390 inet_sendmsg+0x6a/0x70 sock_sendmsg+0x9d/0xc0? sockfd_lookup_light+0x12/0x80 __sys_sendto+0x10e/0x160 ? syscall_enter_from_user_mode+0x20/0x60? __this_cpu_preempt_check+0x13/0x20? lockdep_hardirqs_on+0x82/0x110 __x64_sys_sendto+0x1f/0x30 do_syscall_64+0x38/0x90 Entry_SYSCALL_64_after_hwframe+0x63/0xcd Rechace la selección de sockets que no sean TCP como destino de redireccionamiento desde un programa BPF sk_msg para evitar el bloqueo. Cuando lo intente, el usuario recibirá un error EACCES de la llamada al sistema send/sendto/sendmsg().

References

Sources

SourceRecordLicence
CVE ListCVE-2023-52523 changed 2026-08-05CVE Terms of Use
NVDCVE-2023-52523 changed 2026-08-04Public domain