CVE-2021-47131·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: net/tls: Fix use-after-free after the TLS device goes down and up When a netdev with active TLS offload goes down, tls_device_down is called to stop the offload and tear down the TLS context. However, the socket stays alive, and it still points to the TLS context, which is now deallocated. If a netdev goes up, while the connection is still active, and the data flow resumes after a number of TCP retransmissions, it will lead to a use-after-free of the TLS context. This commit addresses this bug by keeping the context alive until its normal destruction, and implements the necessary fallbacks, so that the connection can resume in software (non-offloaded) kTLS mode. On the TX side tls_sw_fallback is used to encrypt all packets. The RX side already has all the necessary fallbacks, because receiving non-decrypted packets is supported. The thing needed on the RX side is to block resync requests, which are normally produced after receiving non-decrypted packets. The necessary synchronization is implemented for a graceful teardown: first the fallbacks are deployed, then the driver resources are released (it used to be possible to have a tls_dev_resync after tls_dev_del). A new flag called TLS_RX_DEV_DEGRADED is added to indicate the fallback mode. It's used to skip the RX resync logic completely, as it becomes useless, and some objects may be released (for example, resync_async, which is allocated and freed by the driver).
- Severity
- high
- Software
- Kernel
- Fixed in
- 5.12.10
- Published
- 2024-03-15
Affected versions
From: 5.11
Until: 5.12.10
Fixed in: 5.12.10
How to fix this CVE
Update your Linux kernel to version 5.12.10 or later to remediate CVE-2021-47131, which causes memory corruption when TLS offload devices transition offline and back online. This vulnerability can lead to kernel crashes or potential privilege escalation if the freed TLS context is reused. Prioritize this update for systems running kernel versions 5.11 through 5.12.9 that actively use TLS hardware offloading.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Check your current kernel version: uname -r | grep -E '^5\.(11|12\.[0-9](?!0))' to identify if you are running an affected version between 5.11 and 5.12.9
- Verify TLS offload capability is enabled: grep -i tls_device /proc/net/protocols or ethtool -k <interface> | grep tls to see if hardware TLS offloading is active on any network interface
- Monitor kernel logs for use-after-free indicators: dmesg | grep -i 'use.after.free\|kasan\|memory corruption\|tls_device' to check for exploitation attempts
- Confirm the fix is applied by running uname -r and verifying the version is 5.12.10 or later
FAQ
What is CVE-2021-47131?
CVE-2021-47131 is a use-after-free vulnerability in Linux kernel's TLS device offloading code. When a network device with active TLS offload goes down and then comes back up, the kernel fails to properly manage the TLS context lifecycle, allowing freed memory to be accessed, leading to potential kernel crashes or code execution.
Is CVE-2021-47131 being actively exploited?
No, this vulnerability is not currently listed in CISA's Known Exploited Vulnerabilities (KEV) catalog and no public exploits are available. However, the high CVSS score of 7.8 and the local privilege escalation potential warrant timely patching.
What versions of Kernel are affected by CVE-2021-47131?
Linux kernel versions 5.11 through 5.12.9 are affected. The vulnerability was fixed in kernel 5.12.10.
How do I check if my server is vulnerable to CVE-2021-47131?
Run 'uname -r' to check your kernel version. If it shows 5.11.x or 5.12.0 through 5.12.9, your system is vulnerable. Additionally, verify TLS offloading is active with 'ethtool -k <interface> | grep tls' on network interfaces that have devices capable of TLS offloading.
Does Defensia detect CVE-2021-47131?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel package is installed on a monitored server, CVE-2021-47131 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/0f1e6fe66977a864fe850522316f713d7b926fd9
- https://git.kernel.org/stable/c/c55dcdd435aa6c6ad6ccac0a4c636d010ee367a4
- https://git.kernel.org/stable/c/f1d4184f128dede82a59a841658ed40d4e6d3aa2
- https://git.kernel.org/stable/c/0f1e6fe66977a864fe850522316f713d7b926fd9
- https://git.kernel.org/stable/c/c55dcdd435aa6c6ad6ccac0a4c636d010ee367a4
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47131. Free for 1 server.
Get started free