CVE-2025-21739·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: scsi: ufs: core: Fix use-after free in init error and remove paths devm_blk_crypto_profile_init() registers a cleanup handler to run when the associated (platform-) device is being released. For UFS, the crypto private data and pointers are stored as part of the ufs_hba's data structure 'struct ufs_hba::crypto_profile'. This structure is allocated as part of the underlying ufshcd and therefore Scsi_host allocation. During driver release or during error handling in ufshcd_pltfrm_init(), this structure is released as part of ufshcd_dealloc_host() before the (platform-) device associated with the crypto call above is released. Once this device is released, the crypto cleanup code will run, using the just-released 'struct ufs_hba::crypto_profile'. This causes a use-after-free situation: Call trace: kfree+0x60/0x2d8 (P) kvfree+0x44/0x60 blk_crypto_profile_destroy_callback+0x28/0x70 devm_action_release+0x1c/0x30 release_nodes+0x6c/0x108 devres_release_all+0x98/0x100 device_unbind_cleanup+0x20/0x70 really_probe+0x218/0x2d0 In other words, the initialisation code flow is: platform-device probe ufshcd_pltfrm_init() ufshcd_alloc_host() scsi_host_alloc() allocation of struct ufs_hba creation of scsi-host devices devm_blk_crypto_profile_init() devm registration of cleanup handler using platform-device and during error handling of ufshcd_pltfrm_init() or during driver removal: ufshcd_dealloc_host() scsi_host_put() put_device(scsi-host) release of struct ufs_hba put_device(platform-device) crypto cleanup handler To fix this use-after free, change ufshcd_alloc_host() to register a devres action to automatically cleanup the underlying SCSI device on ufshcd destruction, without requiring explicit calls to ufshcd_dealloc_host(). This way: * the crypto profile and all other ufs_hba-owned resources are destroyed before SCSI (as they've been registered after) * a memleak is plugged in tc-dwc-g210-pci.c remove() as a side-effect * EXPORT_SYMBOL_GPL(ufshcd_dealloc_host) can be removed fully as it's not needed anymore * no future drivers using ufshcd_alloc_host() could ever forget adding the cleanup
- Severity
- high
- Software
- Kernel
- Fixed in
- 6.13.3
- Published
- 2025-02-27
Affected versions
From: 6.13
Until: 6.13.3
Fixed in: 6.13.3
How to fix this CVE
Update your Linux kernel to version 6.13.3 or later to resolve a use-after-free vulnerability in the UFS (Universal Flash Storage) crypto profile initialization code. This flaw occurs when the crypto cleanup handler attempts to access memory that was already freed during driver removal or error handling. Systems running kernel versions 6.13.0 through 6.13.2 should prioritize this update to prevent potential kernel crashes or privilege escalation.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Check your kernel version: uname -r — verify if it falls in the range 6.13.0 to 6.13.2
- Confirm UFS crypto support is enabled: grep -i 'BLK_CRYPTO' /boot/config-$(uname -r) — if output shows y or m, the vulnerable code path is reachable
- Search kernel logs for use-after-free crashes: sudo journalctl -b | grep -i 'use-after-free\|ufs\|crypto_profile' — look for stack traces mentioning blk_crypto_profile_destroy_callback
- After patching, verify the new kernel: uname -r — confirm version is 6.13.3 or higher, then reboot if kernel was updated
FAQ
What is CVE-2025-21739?
CVE-2025-21739 is a use-after-free vulnerability in the Linux kernel's UFS driver where the block crypto profile cleanup handler attempts to access memory that was already deallocated during driver removal or initialization failure, potentially causing kernel crashes or data corruption.
Is CVE-2025-21739 being actively exploited?
No, there is no evidence of active exploitation in the wild. This vulnerability requires local access and is primarily a kernel stability issue rather than a remote attack vector.
What versions of Kernel are affected by CVE-2025-21739?
Kernel versions 6.13.0, 6.13.1, and 6.13.2 are affected. Version 6.13.3 and later contain the fix.
How do I check if my server is vulnerable to CVE-2025-21739?
Run uname -r to check your kernel version — if it shows 6.13.0 through 6.13.2 and UFS/crypto support is compiled in, you are vulnerable. You can verify crypto support with: grep BLK_CRYPTO /boot/config-$(uname -r)
Does Defensia detect CVE-2025-21739?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2025-21739 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2025-21739. Free for 1 server.
Get started free