CVE-2023-52986: bpf, sockmap: Check for any of tcp_bpf_prots when cloning a listener
In the Linux kernel, the following vulnerability has been resolved:
bpf, sockmap: Check for any of tcpbpfprots when cloning a listener
A listening socket linked to a sockmap has its skprot overridden. It points to one of the struct proto variants in tcpbpfprots. The variant depends on the socket's family and which sockmap programs are attached.
A child socket cloned from a TCP listener initially inherits their skprot. But before cloning is finished, we restore the child's proto to the listener's original non-tcpbpfprots one. This happens in tcpcreateopenreqchild -> tcpbpfclone.
Today, in tcpbpfclone we detect if the child's proto should be restored by checking only for the TCPBPFBASE proto variant. This is not correct. The skprot of listening socket linked to a sockmap can point to to any variant in tcpbpfprots.
If the listeners skprot happens to be not the TCPBPFBASE variant, then the child socket unintentionally is left if the inherited skprot by tcpbpfclone.
This leads to issues like infinite recursion on close [1], because the child state is otherwise not set up for use with tcpbpfprot operations.
Adjust the check in tcpbpfclone to detect all of tcpbpfprots variants.
Note that it wouldn't be sufficient to check the socket state when overriding the skprot in tcpbpfupdateproto in order to always use the TCPBPFBASE variant for listening sockets. Since commit b8b8315e39ff ("bpf, sockmap: Remove unhash handler for BPF sockmap usage") it is possible for a socket to transition to TCPLISTEN state while already linked to a sockmap, e.g. connect() -> insert into map -> connect(AFUNSPEC) -> listen().
[1]: https://lore.kernel.org/all/00000000000073b14905ef2e7401@google.com/
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
ubuntu/linux-aws-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1036.40~20.04.1 - Upgrade
Upgrade
ubuntu/linux-azure-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1038.45~20.04.1 - Upgrade
Upgrade
ubuntu/linux-gcp-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1034.42~20.04.1 - Upgrade
Upgrade
ubuntu/linux-hwe-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-72.79~20.04.1 - Upgrade
Upgrade
ubuntu/linux-intel-iotg-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1030.35~20.04.1 - Upgrade
Upgrade
ubuntu/linux-lowlatency-hwe-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-72.79~20.04.1 - Upgrade
Upgrade
ubuntu/linux-nvidia-tegra-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1014.14~20.04.1 - Upgrade
Upgrade
ubuntu/linux-oracle-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1035.41~20.04.1 - Upgrade
Upgrade
ubuntu/linux-riscv-5.15to a version that resolves this vulnerability.Fixed in 5.15.0-1033.37~20.04.1 - Upgrade
Upgrade
ubuntu/linuxto a version that resolves this vulnerability.Fixed in 5.15.0-72.79 - Upgrade
Upgrade
ubuntu/linux-awsto a version that resolves this vulnerability.Fixed in 5.15.0-1036.40 - Upgrade
Upgrade
ubuntu/linux-azureto a version that resolves this vulnerability.Fixed in 5.15.0-1038.45 - Upgrade
Upgrade
ubuntu/linux-azure-fdeto a version that resolves this vulnerability.Fixed in 5.15.0-1038.45.1 - Upgrade
Upgrade
ubuntu/linux-gcpto a version that resolves this vulnerability.Fixed in 5.15.0-1034.42 - Upgrade
Upgrade
ubuntu/linux-gketo a version that resolves this vulnerability.Fixed in 5.15.0-1033.38 - Upgrade
Upgrade
ubuntu/linux-gkeopto a version that resolves this vulnerability.Fixed in 5.15.0-1020.25 - Upgrade
Upgrade
ubuntu/linux-ibmto a version that resolves this vulnerability.Fixed in 5.15.0-1030.33 - Upgrade
Upgrade
ubuntu/linux-intel-iotgto a version that resolves this vulnerability.Fixed in 5.15.0-1030.35 - Upgrade
Upgrade
ubuntu/linux-kvmto a version that resolves this vulnerability.Fixed in 5.15.0-1033.38 - Upgrade
Upgrade
ubuntu/linux-lowlatencyto a version that resolves this vulnerability.Fixed in 5.15.0-72.79 - Upgrade
Upgrade
ubuntu/linux-nvidiato a version that resolves this vulnerability.Fixed in 5.15.0-1025.25 - Upgrade
Upgrade
ubuntu/linux-oracleto a version that resolves this vulnerability.Fixed in 5.15.0-1035.41 - Upgrade
Upgrade
ubuntu/linux-raspito a version that resolves this vulnerability.Fixed in 5.15.0-1029.31 - Upgrade
Upgrade
ubuntu/linux-bluefieldto a version that resolves this vulnerability.Fixed in 5.15.0-1017.19 - Upgrade
Upgrade
ubuntu/linux-intel-iot-realtimeto a version that resolves this vulnerability.Fixed in 5.15.0-1028.33 - Upgrade
Upgrade
ubuntu/linux-realtimeto a version that resolves this vulnerability.Fixed in 5.15.0-1038.41 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.11-1 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.168 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.93 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.11 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.115-2Fixed in 7.2.15-1 - Compensating control
Update tcp_bpf_clone to detect all variants in tcp_bpf_prots when cloning a listener, and restore the child socket's sk_prot to the listener's original non-tcp_bpf_prots proto.
Event History
Frequently Asked Questions
What is the severity of CVE-2023-52986?
CVE-2023-52986 has been classified with a high severity level due to the potential compromise of listening sockets in the Linux kernel.
How do I fix CVE-2023-52986?
The fix for CVE-2023-52986 involves updating your Linux kernel to the latest version where this vulnerability has been patched.
What systems are affected by CVE-2023-52986?
CVE-2023-52986 affects various versions of the Linux kernel that utilize sockmap functionality.
What type of vulnerability is CVE-2023-52986?
CVE-2023-52986 is a security vulnerability in the Linux kernel related to BPF and sockmap that allows manipulation of socket protocol structures.
Can CVE-2023-52986 be exploited remotely?
Yes, CVE-2023-52986 can potentially be exploited remotely if an attacker can interact with the affected socket configurations.