CVE-2021-47131: net/tls: Fix use-after-free after the TLS device goes down and up
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).
Security readout for executives and security teams
Plain-English summary
CVE-2021-47131 is a Linux kernel bug in TLS hardware offload handling. If a network device with active TLS offload goes down and later comes back up while the connection survives, the kernel can reference freed TLS context memory. Exposure appears limited to systems using kTLS device offload.
Executive priority
Treat as a targeted kernel maintenance item, highest for infrastructure using TLS hardware offload or network failover. There is no supplied evidence of broad exploitation, but kernel memory-safety bugs merit timely patching where exposure exists.
Technical view
The flaw is a use-after-free in Linux net/tls. tls_device_down tore down offload state while the socket retained a pointer to the TLS context. When the interface returned and traffic resumed after retransmissions, the stale context could be used. The fix keeps context lifetime aligned with normal destruction and falls back to software kTLS.
Likely exposure
Likely exposed systems are Linux hosts running affected kernels with TLS device offload enabled on capable network hardware and active TLS connections during network-device down/up events. Systems not using kTLS device offload appear less relevant based on the supplied description.
Exploitation context
The source bundle does not cite active exploitation, and KEV status is false. The described trigger requires an active TLS offloaded connection, network-device teardown, device recovery, and resumed traffic. Impact details beyond use-after-free are not provided.
Researcher notes
The affected-version data in the bundle is incomplete and partly commit-like, so rely on distribution backports and kernel stable references for exact applicability. Key behavior is graceful teardown: deploy software fallback before releasing driver resources and skip RX resync in degraded mode.
Mitigation direction
Apply Linux kernel updates containing the referenced stable fixes.
Prioritize hosts using TLS hardware offload on production network interfaces.
If patching is delayed, consult vendor guidance on disabling TLS device offload.
Track distribution advisories for backported fixed kernel packages.
Validation and detection
Inventory Linux kernel versions against vendor advisories and the referenced stable commits.
Identify whether kTLS device offload is enabled on network adapters.
Review affected services for TLS offload usage during interface failover or resets.
Confirm patched kernels preserve TLS connections through software fallback behavior.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2021-47131 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.